- Notifications
You must be signed in to change notification settings - Fork 3.1k
Implement a preloader. #2015
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
base: trunk
Are you sure you want to change the base?
Implement a preloader. #2015
Conversation
6a6fbaa to b9c16aa Compare b9c16aa to 6338df4 Compare 6338df4 to 8f67690 Compare | // Preload files. | ||
| $dangerous_paths = array( '', '.', '/' ); | ||
| | ||
| foreach ( $preload_paths as $path ) { |
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.
take a look at validate_file(), I suspect you are doubling up a few things here.
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.
Nice @peterwilsoncc, hadn't thought of that at the time. validate_file() should work nicely here.
| | ||
| // Add errors to the overall list. | ||
| if ( is_wp_error( $result ) ) { | ||
| $errors->errors = array_merge( $errors->errors, $result->errors ); |
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.
Oops. This should actually use WP_Error::merge_from().
i.e.
$errors->merge_from( $result );| // This is a directory. Recurse. | ||
| if ( $wp_filesystem->is_dir( $fullpath ) ) { | ||
| // Get the file or subdirectory names. | ||
| $contents = array_keys( $wp_filesystem->dirlist( $fullpath, false, false ) ); |
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'll split this out to first check if dirlist() has returned false. If it has, I can add a WP_Error for dirlist_not_returned, then continue.
| The tests seem inadequate. If is I'm not familiar with the WordPress build process itself, but how I would approach this is: Use Composer\Autoload\ClassMapGenerator::createMap() to build a classmap from the autoload key in the library. I worked on a library for prefixing namespaces for WordPress plugins to avoid conflicts: https://github.com/BrianHenryIE/strauss (my point was to show how I've thought of this in terms of WordPress already. But it's honest to say: The same code could be used to rename namespaces, i.e. the WpOrg WPorg WordPress Wordpress namespace discussion that was earlier.) Again, I'm not familiar with the WordPress build process and how it could use Composer libraries, but I do see how Strauss's functionality could be split into another library that helps this issue – ultimately listing all classes in a library and ordering them based on what they require (extend/implement/use) before |
| I put together a proof of concept here: https://github.com/BrianHenryIE/composer-require-once It's really just one function in one class, with a test running against Requests. Requires composer/composer and nikic/php-parser. |
This PR implements a preloader for the upgrade process.
wp-includes/Requestsdirectory.wp-includes/Requests/Autoload.phpon WP < 5.9.Source
Tests
Trac ticket: https://core.trac.wordpress.org/ticket/54589