-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add directory support to WP_Filesystem_Direct::move().
#3909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add directory support to WP_Filesystem_Direct::move().
#3909
Conversation
ccd19bd to
14cfb77
Compare
14cfb77 to
20a411e
Compare
peterwilsoncc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few notes inline.
0602168 to
cdefe50
Compare
6ed97ca to
235bf29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently encountered an edge case where $from and $to differed only by a trailing slash. This resulted in the clearing of $to prior to rename() deleting the source. We could easily add a guard for that case as in the following.
if ( trailingslashit( $from ) === trailingslashit( $to ) ) {
return false;
}Would need to update @return also.
3892132 to
5378949
Compare
SergeyBiryukov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the feedback appears to be addressed.
With no new concerns raised, I believe this is now ready for commit?
Co-authored-by: Sergey Biryukov <[email protected]>
Co-authored-by: Sergey Biryukov <[email protected]>
Co-authored-by: Sergey Biryukov <[email protected]>
Co-authored-by: Sergey Biryukov <[email protected]>
Co-authored-by: Sergey Biryukov <[email protected]>
…iling slash and/or case. Props @afragen
Props @afragen, @SergeyBiryukov Co-authored-by: Andy Fragen <[email protected]>
Props @azaozz, @afragen, @SergeyBiryukov Co-authored-by: Andrew Ozz <[email protected]>
2f27c7f to
8aa303a
Compare
8aa303a to
809f893
Compare
|
For clarity: The latest push was just to rebase on |
peterwilsoncc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more notes and a question.
This is in really good shape and I think it will be good for the first beta.
tests/phpunit/tests/filesystem/wpOpcacheInvalidateDirectory.php
Outdated
Show resolved
Hide resolved
tests/phpunit/tests/filesystem/wpOpcacheInvalidateDirectory.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Sergey Biryukov <[email protected]>
felixarntz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peterwilsoncc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I think this is ready.
@felixarntz The 200ms delay is a necessary evil due to excessive caching in some set ups (VirtualBox been the most likely to be hit via VVV, Chassis and others). Without it, the wrong files can be affected by multiple calls to move_dir() and cause fatal errors.
I think it's the least bad solution, and even with the delay the switch to move_dir() is substantially faster in my testing. I suspect the reason WP wasn't hitting the caching issue in the past was because copy_dir() is so slow.
azaozz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking this is ready too. Only the docblock updates for the other ::move() methods.
felixarntz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to commit. We can probably also commit #3963 right after. 🎉
This PR adds directory support to
WP_Filesystem_Direct::move()for consistency with the otherWP_Filesystem_*classes.This includes:
WP_Filesystem_Direct::move().wp_opcache_invalidate_directory(), to recursively callwp_opcache_invalidate().move_dir(), for extender convenience and more informative failure reasons.move_dir().wp_opcache_invalidate_directory().Testing instructions
Steps to test
WP_DEBUGandWP_DEBUG_LOGare set totrue.Dashboard > Updatesand update one or more plugins/themes.Plugins > Installed pluginsand update one or more plugins.Appearance > Themesand update some themes.Expected results
All updates should complete as normal, with no errors/warnings/notices in
wp-content/debug.log.Trac ticket: https://core.trac.wordpress.org/ticket/57375