Last modified: 2010-05-15 15:54:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 14670 - Autoload conflicts with other PHP packages in memory that also autoload
Autoload conflicts with other PHP packages in memory that also autoload
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.12.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-28 03:29 UTC by Michael Morris
Modified: 2010-05-15 15:54 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patched Autoloader file that has code to use spl_autoload_register (20.09 KB, patch)
2008-06-28 03:29 UTC, Michael Morris
Details

Description Michael Morris 2008-06-28 03:29:57 UTC
Created attachment 5031 [details]
Patched Autoloader file that has code to use spl_autoload_register

This is a feature request to improve interoperability between MediaWiki and other PHP packages by slightly changing how the autoloader is established. Currently MediaWiki directly defines PHP 5's magic __autoload function. However, if another application has already registered an __autoload this call silently fails and the program crashes the first time it tries to start a class.

The solution as of PHP 5.1.2 is function spl_autoload_register().  This function will register Wiki's autoloader.  When the Zend engine has an undefined class it will iterate across the autoloaders until one of them returns true (presumably because it found the class).

Attached is a corrected Autoload.php file with the changes necessary to use this function. Further if the function is not defined it will define a magic __autoload function for backwards compatibility.

Forgive me if I mess this up - I've not worked with bugzilla before.
Comment 1 Michael Morris 2008-06-28 03:32:13 UTC
Forgot to mention - for compliance with other autoloaders the wfAutoload function now returns boolean true or false, previously it returned void.
Comment 2 Chad H. 2008-06-29 03:42:54 UTC
AutoLoader is already using spl_autoload_register(). Changed AutoLoader::autoload() to return false on failure instead in r36776. Nothing appears to break here, but it could use some additional eyes. I do think that returning false seems like a more logic choice, as it allows for better testing  $newClass = new Class() failures rather than an explicit "Class X not found" PHP error. 
Comment 3 Michael Morris 2008-06-30 04:40:02 UTC
Returning false also prompts the zend engine to fire the next autoload method on the stack. I would advise against the use of eval("$newClass = new Class():"); because that prevents other any autoloaders that where defined after the wiki autoloader from working. Once a class is defined it can't be undefined - best to fail hard here and give other autoloaders that might be in place a chance to work.
Comment 4 Chad H. 2008-06-30 12:50:26 UTC
Eval() isn't used _anywhere_ in the code.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links