HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Courteous Autoload Method
Vanilla 2 Code Suggestion:
use spl_autoload_register('your_autoload_function'); instead of __autoload($ClassName); so other code may register their own autoload function.
in /library/core/functions.general.php
use spl_autoload_register('your_autoload_function'); instead of __autoload($ClassName); so other code may register their own autoload function.
in /library/core/functions.general.php
Tagged:
1
Comments
spl_autoload_register('vanillaAutoload');
@andyblackwell, @chriscoyier, are there any drawbacks to sp_autoload_register that you know of?
I got difficulties to add a third party library which made use of spl_autoload_register to register its autoloader.
It's not very hard once we know the tricks to register the __autoload method on the __autoload stack (see http://www.php.net/manual/en/function.spl-autoload-register.php) but it won't be a solution if 2 enabled plugins do the same, so vanilla definitely need to register its autoloader with spl_autoload_register.
the main change was to rename __autoload to for example vanillaAutoloader and call spl_autoload_register just after the function declaration as suggested by chriscoyier.
While googling for my autoload problem with vanilla I found this :
http://aaronsaray.com/blog/2008/09/29/php-spl-autoload-3-simple-rules-you-must-follow/
And one of his rule is that "Custom autoload functions should not have a failure consequence"
I think this his because a third party library could check also with function_exist if an autoload is already defined and add it to the stack if TRUE with spl_autoload_register('__autoload').
So imo it's better to remove the __autoload method if it's not needed anymore and "just let it crash" if another part of the code use it instead of spl_autoload_call
Our code doesn't call it anymore though.