[wp-trac] [WordPress Trac] #13436: WordPress class_exists() conflicts with __autoload() and php_auto_prepend

WordPress Trac noreply at wordpress.org
Sun Jun 22 15:58:45 UTC 2014


#13436: WordPress class_exists() conflicts with __autoload() and php_auto_prepend
----------------------------+------------------------------
 Reporter:  galbus          |       Owner:
     Type:  enhancement     |      Status:  reopened
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Bootstrap/Load  |     Version:  3.0
 Severity:  minor           |  Resolution:
 Keywords:  needs-patch     |     Focuses:
----------------------------+------------------------------
Changes (by jcjcc):

 * keywords:  needs-patch close => needs-patch


Comment:

 OK, fine. Sorry for the duplicate ticket, this ticket seemed dead.

 To add to why this seems not to have been committed despite a patch being
 given by tychay, one of the developers commented
 > Autoloaders should be using file_exists.
 I am not writing my own autoloader, I am calling
 spl_autoload_extensions(".class.php") and then spl_autoload_register()
 which registers the default autoloader. This loads a namespaced class
 "\core\blah" by looking in for "blah.class.php" in the folder "core".

 But that's besides the point -- class_exists is documented to *throw an
 error* if the class cannot be loaded (it has nothing to do with
 file_exists...) and the second parameter is true (which is default). Thus,
 the code as it is right now is incorrect.

 It just so happens that usually no autoloader is registered (or if plugins
 use autoloaders, their code is run after the erroneous core code), so
 nobody notices. I don't understand rmccue's "code churn" argument.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/13436#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list