Skip to content

Conversation

@afragen
Copy link
Member

@afragen afragen commented Dec 27, 2022

copy_dir() is a recursive file copy for directories and is used when updating plugins, themes, and core.

There are several tickets related to timeouts and optimization of the update process. As part of Rollback #51857, a new function move_dir() and a new filter #56057 were introduced. This ticket is an improvement upon #56057.

Optimizing the plugin/theme update process can be solved using the move_dir() function and a filter similar to #56057.

#57357 was opened to add move_dir() to core. This ticket is to add the new filter.

The new filter would easily allow the substitution of move_dir for copy_dir adding more efficiency to the plugin/theme update process by having the user add a simple filter. This could improve the efficiency and performance for 99+% of users who opt-in and will likely fix #53832, #54166, and #34676.

add_filter( 'upgrader_copy_directory', function($callback) {
    return 'move_dir';
}, 10, 1 );

I believe the use cases are sufficient to merit inclusion to core, additionally both of these have been tested rigorously in the Rollback PR/feature plugin.

Trac ticket: https://core.trac.wordpress.org/ticket/57386

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@afragen afragen marked this pull request as ready for review December 30, 2022 21:41
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in Slack and posted on trac a couple of weeks ago, I don't think this is a suitable filter for Core.

It provides no general purpose benefit to theme and plugin developers.

Please use the custom actions hooks for testing the rollback plugin.

@afragen afragen closed this Jan 12, 2023
@afragen afragen force-pushed the upgrader-copy-directory-filter branch from b4ce18e to 344c4dc Compare January 12, 2023 12:42
@afragen afragen reopened this Jan 12, 2023
@afragen
Copy link
Member Author

afragen commented Jan 12, 2023

PR now using switch filter.

if ( ! apply_filters( 'upgrader_use_move_dir', false, ... ) {
    copy_dir();
} else {
    move_dir();
}

@afragen
Copy link
Member Author

afragen commented Jan 26, 2023

Closing in favor of PR3911

@afragen afragen closed this Jan 26, 2023
@afragen afragen deleted the upgrader-copy-directory-filter branch January 26, 2023 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants