[wp-trac] [WordPress Trac] #36335: Next generation: core autoloader proposal
WordPress Trac
noreply at wordpress.org
Thu Apr 21 14:20:17 UTC 2016
#36335: Next generation: core autoloader proposal
-----------------------------+-----------------------------
Reporter: dnaber-de | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+-----------------------------
Comment (by greg1anderson):
The comments by @schlessera, above, are extremely sensible. I wanted to
expand slightly on these thoughts, lest individual plugin authors become
tempted to provide their own autoloading prior to its availability in WP
core. This is technically possible, but runs the risk of running into some
pretty serious "dependency hell" when people mix-and-match their
extensions.
It is clear that if plugin "A" requires some library version 1.x, and
another library requires the same library at version 2.x, that can never
work. However, if you implement plugin dependencies by giving each plugin
its own autoloader, then you can run into some pretty extreme and hard-to-
debug scenarios if you mix the same minor versions (e.g. 1.0.1 and 1.0.2)
of the same dependency. The
[https://github.com/composer/composer/issues/3852 problem with including
different versions of Composer twice] has already been mentioned above,
but this same problem can extend to any common library used in any two
plugins. For a more complete explanation, see [https://pantheon.io/blog
/trouble-two-autoloaders The Trouble with Two Autoloaders].
This problem cannot be solved by implementing your own common autoloader.
It can only be solved by having a single autoloader for the entire
application -- e.g. a single composer.json at the root of the project,
where plugins are added via `composer require`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36335#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list