[wp-trac] [WordPress Trac] #36335: Next generation: core autoloader proposal
WordPress Trac
noreply at wordpress.org
Mon Aug 29 06:58:24 UTC 2016
#36335: Next generation: core autoloader proposal
-----------------------------+------------------
Reporter: dnaber-de | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 4.7
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+------------------
Comment (by Clorith):
Replying to [comment:112 schlessera]:
> > Another thing that needs clarification: if we have autoloading, would
a plugin be able to stop some of the core classes from loading, noop or
replace them etc. That would be a backwards compatibility disaster down
the road :)
>
> Yes, a plugin could potentially do this if it would `require` a class
with the same name before it was loaded through the autoloader. However, I
can't see why a plugin would want to do that, and it would probably break
half of the time, because autoloading means there's no set point in time
where you know the class was or wasn't loaded any more. Also, I think
there's a number of classes and functions that contain a `class_exists()`
check before being loaded, so these could just as easily be replaced by a
plugin version.
This is the part that worries me, you say they shouldn't, I agree. But
from experience, they will, they most definitely will.
I can guarantee that this will lead to an increase in broken setups,
plugins and themes will re-declare classes, they won't use `class_exists`
(because why should they, core will only make this a problem if core is
loaded before them, there's not much consideration for other plugins and
themes in that regard), they will have class name collisions with other
plugins that are trying to be just as clever.
Just look at 4.6 which had this with a single generically named function
for `the_post_thumbnail_caption` which themes and plugins were already
using, already declared function and classes means server error, this
can't be fixed without accessing the file system in some way, which is a
technical step many of our users are not comfortable making (and we
shouldn't force upon them if we can avoid it).
I was thinking of ways we could possibly sign core classes so we don't
auto load plugin/theme ones as replacements, but that won't work if they
just do an include or require right off the bat, which is the more likely
scenario than them piggybacking off a core auto loader.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36335#comment:113>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list