Autoload WordPress Core classes using native PHP classloader with static classmap#12089
Autoload WordPress Core classes using native PHP classloader with static classmap#12089sun wants to merge 243 commits into
Conversation
Co-authored-by: Sergey Biryukov <sergeybiryukov.ru@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds WP_Exception, WP_Filter_Sentinel, WP_Block_Processor, WP_Block_Metadata_Registry, WP_Connector_Registry, WP_Icons_Registry, WP_URL_Pattern_Prefixer, WP_Speculation_Rules, the abilities-api classes, the ai-client classes, and the new REST API controllers (abilities v1, icons) to WP_Autoload::CLASSES_PATHS. Also moves WP_Filter_Sentinel fallback require inside the !WP_Autoload guard in plugin.php, consistent with the WP_Hook treatment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Revert wpdb from classmap: class-wpdb.php defines global constants (OBJECT, ARRAY_A, …) at file scope that must be available before the first DB query. Restores require_once inside require_wp_db() in load.php. - Revert wp_importer from classmap: class-wp-importer.php defines the global function get_cli_args() outside the class body; importer plugins load the file themselves. - Document both exclusions and the multi-class-per-file list in the class-wp-autoload.php file docblock. - Switch require → require_once in autoload_core() so that files mapping multiple classes (class-json.php, class-wp-http-streams.php, etc.) are never included twice, and add an explanatory comment. - Add inline comment to wp-settings.php explaining why the safety-net require_once of class-wp-autoload.php is kept there. - Fix test regex to match final/abstract/readonly class, interface, trait, and enum declarations, not just bare class. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…p-autoload.php. WP_Autoload::register() is now called explicitly at each of the six bootstrap entry points (wp-load.php, wp-settings.php, index.php, setup-config.php, load-styles.php, load-scripts.php) so the class file is a pure definition with no side effects on include. Also restores the explicit require_once of class-wp-importer.php in wp-admin/includes/import.php, matching the exclusion from the classmap introduced in the previous commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @sun! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket: https://core.trac.wordpress.org/ticket/60414
This resurrects and expands @aristath's great work in #3470
Use of AI Tools
AI assistance: Yes
Tool(s): Anthrophic Claude
Model(s): Sonnet-4.6
Used for: Updating code for latest trunk; final architecture and implementation were reviewed and edited by me.
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.