Opened 13 months ago
Last modified 12 months ago
#20523 new feature request
Disable autoloader when using class_exists()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | 3.3.1 |
| Severity: | normal | Keywords: | |
| Cc: | kpayne@… |
Description
A couple of files inside the /wp-includes/pomo directory use class_exists() the wrong way, for example in /wp-includes/pomo/entry.php :
if ( !class_exists( 'Translation_Entry') ):
It should be:
if ( !class_exists( 'Translation_Entry', false) ):
The second parameter 'false' disables autoloading. This is important because I'm integrating some WP functions into another existing website which already comes with an Autoloader for some classes = confusion.
This should be easy to fix. Thanks :)
Change History (2)
- Cc kpayne@… added
- Type changed from defect (bug) to feature request
Done, that works. But really, it's not cool and I'll remove that code once this bug has been fixed.
By the way, WordPress should come with an own bootstrapper to load only the pieces we need with SHORTINIT. Do not like the code there in that discussion forum. Shouldn't be like that.

Can you add your own autoloader to the stack before you add WordPress to your existing codebase?
spl_autoload_register( function( $className ) { // If you're the last on the stack, the other autoloader should // take care of its own classes, but if it fails to find $className // you'll end up here, just don't throw an exception } );This might prevent the errors you're seeing.
You could also look at loading only the pieces of WordPress you need with SHORTINIT
http://wordpress.org/support/topic/load-wp-core-in-another-framework-shortinit-wp_query?replies=3