[wp-trac] [WordPress Trac] #36926: Autoloading: Introduce compatibility shim for spl_autoload_register

WordPress Trac noreply at wordpress.org
Tue May 24 06:42:39 UTC 2016


#36926: Autoloading: Introduce compatibility shim for spl_autoload_register
-----------------------------------+------------------
 Reporter:  rmccue                 |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  4.6
Component:  General                |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------

Comment (by dd32):

 @rmccue [attachment:36926.2.diff] seems pretty sane to me.
 The obvious breakage is when something else is defining `__autoload()`,
 but I think that's something we're just going to have to expect - there's
 no way to polyfill it in those cases.

 Replying to [comment:3 tfrommen]:
 > '''Improve `__autoload()`'''
 > `$spl_autoloaders` is global, so anyone can put into it whatever they
 like. So we should check for `is_callable` for each autoloader function
 '''inside `__autoload()`''', and `continue` if it isn't.
 >
 > '''Improve `spl_autoload_functions()`'''
 > Since `$spl_autoloaders` is, again, a global, and since we don't want to
 argue with SPL, we should make sure we're returning an array.

 Both of these seem like needless checks in this case, if outside code
 modifies the global their warranty is void, just as if they modify the
 global `$wp_filters` arrays, or almost any other global in WordPress for
 that matter.

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


More information about the wp-trac mailing list