[wp-trac] [WordPress Trac] #13436: Wordpress class_exists() conflicts with __autoload() and php_auto_prepend
WordPress Trac
wp-trac at lists.automattic.com
Tue May 18 15:51:26 UTC 2010
#13436: Wordpress class_exists() conflicts with __autoload() and php_auto_prepend
-------------------------+--------------------------------------------------
Reporter: galbus | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Unassigned
Component: General | Version: 3.0
Severity: minor | Keywords: autoload class_exists php_auto_prepend
-------------------------+--------------------------------------------------
== Issue ==
Wordpress core (and many plugins) use class_exists().
http://php.net/manual/en/function.class-exists.php
When Wordpress is integrated with custom/third party applications that use
php_auto_prepend and autoload() to include/require files based on the
$class_name parameter this generates errors as class_exists() triggers the
autoload() and the files cannot be found.
== To reproduce ==
Using php_auto_prepend specify a file to include before every page request
that contains the following PHP code:
{{{
<?php
function __autoload($class) {
include($class.'.php');
}
?>
}}}
Visit any front-end or back-end Wordpress page.
== Solution ==
As there is no autoload() function defined in Wordpress core the
class_exists() should implement the second class_exists() parameter:
{{{
<?php
if (!class_exists('ExampleClass', false)) {
...
}
?>
}}}
This stops calls to __autoload() and would fix the errors seen when
integrating Wordpress with apps that implement this.
I have implemented this and tested it and Wordpress works fine, but I
can't find out where the SVN repo is for Wordpress 3 Beta 2 (the SVN page
on the site takes me to 2.x).
If someone could supply a link for SVN CO of WP3 I can provide the patch.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13436>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list