Bug #71236 [Opn]: Second call of spl_autoload_register() does nothing if it has no arguments

[email protected] ("php at maisqi dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71236&edit=1

 ID:                 71236
 User updated by:    php at maisqi dot com
 Reported by:        php at maisqi dot com
 Summary:            Second call of spl_autoload_register() does nothing
                     if it has no arguments
 Status:             Open
 Type:               Bug
 Package:            SPL related
 Operating System:   Windows and Linux
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

In "Actual results" should be:

   The first block prints one entry; the others print two blocks.


Previous Comments:
------------------------------------------------------------------------
[2015-12-29 12:39:21] php at maisqi dot com

Description:
------------
spl_autoload_register() with no arguments registers spl_autoload(). But if we call spl_autoload_register() with a custom function before, it does nothing.
Nothing in the documentation seems to support this behaviour as valid.

Tested on PHP 5.5 Linux, 5.6 Win64 and 7.01 Win64.

Test script:
---------------
<?php
echo '<pre>';
/**
 * Every one of these code blocks must be run in separated.
 */
// Custom function first; spl_autoload after.
spl_autoload_register(function ($class) {});
spl_autoload_register();
print_r(spl_autoload_functions());	// Prints only one entry.
/*

// Custom function first; spl_autoload after.
spl_autoload_register(function ($class) {});
spl_autoload_register('spl_autoload');
print_r(spl_autoload_functions());	// Prints two entries, as expected.

// spl_autoload first; custom function after.
spl_autoload_register();
spl_autoload_register(function ($class) {});
print_r(spl_autoload_functions());	// Prints two entries, as expected.
*/

Expected result:
----------------
All blocks should print two entries.

Actual result:
--------------
All blocks should print two entries, except the first that only prints one.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71236&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.