[wp-trac] [WordPress Trac] #60414: Core PHP autoloader proposal
WordPress Trac
noreply at wordpress.org
Mon Apr 22 10:52:21 UTC 2024
#60414: Core PHP autoloader proposal
-------------------------------------+-------------------------------------
Reporter: aristath | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit- | Focuses: performance,
tests early | sustainability
-------------------------------------+-------------------------------------
Description changed by aristath:
Old description:
> Using a PHP autoloader can improve performance, and can be seen as a
> first step towards modernizing the WP codebase in the future.
>
> This ticket is a continuation of the discussion on
> [https://core.trac.wordpress.org/ticket/36335 #36335]
> The discussion in the original ticket was derailed many times, so this
> fresh ticket is an opportunity to discuss the Core proposal submitted on
> the [https://make.wordpress.org/core/?p=110295 Make blog]
New description:
Using a PHP autoloader can improve performance, and can be seen as a first
step towards modernizing the WP codebase in the future.
This ticket is a continuation of the discussion on
[https://core.trac.wordpress.org/ticket/36335 #36335]
The discussion in the original ticket was derailed many times, so this
fresh ticket is an opportunity to discuss the Core proposal submitted on
the [https://make.wordpress.org/core/?p=110295 Make blog]
The concerns that were brought-up in the original ticket:
* **PHP 5.2 compatibility**: No longer relevant.
* **Files containing classes also contain other functions**: This has
already been addressed since then. The few instances where this was still
an issue were addressed in the patch/PR.
* **Composer**: Outside the scope of this initial implementation.
* **Overriding Core classes from plugins**: Added a site-health check with
a critical warning in case a Core class is not loaded from the default WP
path.
* **API for plugins/themes to register additional classes**: Outside the
scope of this PR.
* **WordPress is not OOP**: True, it's not currently OOP, but as we
integrate the new editor in WP-Core, more and more OOP concepts creep in
Core. There is definitely a trend, and WP is slowly becoming more OOP than
it used to be. An autoloader will unblock us and allow us to further
optimize and improve Core as we go.
* **What does autoloading do for "loose" functions?**: Nothing. But it
does give us the flexibility to properly group them in classes in the
future, and only load what's needed. But that is a future discussion that
will probably take a few more years.
* **Backwards-compatibility issues**: There are none.
* **Performance**: This patch has a negligible positive effect on
performance. That is not its point. It opens the door to future
improvements that can't be done easily without an autoloader. This is not
an improvement with an immediately tangible outcome, it's just paving the
way for more meaningful future improvements.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60414#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list