[wp-trac] [WordPress Trac] #57386: Add filter to WP_Upgrader::install_package for copy_dir()

WordPress Trac noreply at wordpress.org
Sat Jan 7 15:38:34 UTC 2023


#57386: Add filter to WP_Upgrader::install_package for copy_dir()
-----------------------------+--------------------------
 Reporter:  afragen          |       Owner:  (none)
     Type:  feature request  |      Status:  reopened
 Priority:  normal           |   Milestone:  6.2
Component:  Upgrade/Install  |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:  performance
-----------------------------+--------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:21 azaozz]:
 > Another, "last resort" solution may be to "hide" the new `move_dir()`
 functionality inside one of the rollback functions and use it only for
 rollbacks. Not ideal but will avoid triggering the VB bug. The advantage
 is that it will work for "everybody" out of the box.

 Part of the issue is that `copy_dir()` can be quite slow for large plugins
 (since it copies each file individually and is recursively called for
 subdirectories), so using it both to create a backup of the existing
 plugin version and to install the new plugin version makes the process
 twice as slow and more prone to timeouts, the very issue that `move_dir()`
 was intended to solve.

 This got me thinking though, if we're not introducing rollbacks at this
 time, then the conditions to trigger the bug as outlined in comment:23
 should never happen:

 * Move `oldname` to another location.
 * Move new version `newname` into place, renamed to `oldname`.
 * Delete `oldname` from the other location. 🐞

 What happens instead:

 * Delete `oldname` from the original location.
 * Move new version `newname` into place, renamed to `oldname`.

 So perhaps it is safe enough to just use `move_dir()` here? The filter is
 then just an additional precaution to make this opt-in, which may or may
 not be necessary.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57386#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list