Skip to content

Autoload WordPress Core classes using native PHP classloader with static classmap#12089

Open
sun wants to merge 243 commits into
WordPress:trunkfrom
sun:feat/autoload
Open

Autoload WordPress Core classes using native PHP classloader with static classmap#12089
sun wants to merge 243 commits into
WordPress:trunkfrom
sun:feat/autoload

Conversation

@sun
Copy link
Copy Markdown

@sun sun commented Jun 4, 2026

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.

aristath and others added 27 commits August 1, 2024 11:11
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>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Hi @sun! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

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 WordPress Project

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props aristath.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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