php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61697 spl_autoload_functions returns lambda functions incorrectly
Submitted: 2012-04-11 18:29 UTC Modified: 2013-07-23 18:47 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: stadli at gmx dot de Assigned: aharvey (profile)
Status: Closed Package: SPL related
PHP Version: 5.4.0 OS:
Private report: No CVE-ID: None
 [2012-04-11 18:29 UTC] stadli at gmx dot de
Description:
------------
spl_autoload_functions() doesn't return the names of lambda-functions registered with spl_autoload_register() correctly. Actually it always returns '__lambda_func' for every lambda function so you can't use the result with spl_autoload_unregister() for example.

Test script:
---------------
<?php

function f1($class) { echo "f1: [[$class]]\n"; }
function f2($class) { echo "f2: [[$class]]\n"; }

spl_autoload_register('f1');
spl_autoload_register('f2');
spl_autoload_register(create_function('$class', 'echo "cf1: [[$class]]\n";'));
spl_autoload_register(create_function('$class', 'echo "cf2: [[$class]]\n";'));

var_dump(spl_autoload_functions());
foreach (spl_autoload_functions() AS $func)
{
	spl_autoload_unregister($func);
}
var_dump(spl_autoload_functions());

?>


Expected result:
----------------
All autoload functions are unregistered

Actual result:
--------------
lambda functions aren't unregistered

Patches

bug61697.phpt (last revision 2012-04-12 05:19 UTC by laruence@php.net)
bug61697.patch (last revision 2012-04-12 05:16 UTC by laruence@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-12 05:16 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug61697.patch
Revision:   1334207765
URL:        https://bugs.php.net/patch-display.php?bug=61697&patch=bug61697.patch&revision=1334207765
 [2012-04-12 05:19 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug61697.phpt
Revision:   1334207979
URL:        https://bugs.php.net/patch-display.php?bug=61697&patch=bug61697.phpt&revision=1334207979
 [2012-04-12 05:21 UTC] laruence@php.net
-Status: Open +Status: Analyzed
 [2012-04-12 05:21 UTC] laruence@php.net
I have made a patch for this, but there is a BC break, that is, 
spl_autoload_functions return lambad_function with name "__lambad_function" 
previously.

after patched, it will return string like "lambad_1".
 [2012-04-19 23:52 UTC] felipe@php.net
-Status: Analyzed +Status: Assigned -Assigned To: +Assigned To: colder
 [2013-03-11 04:09 UTC] stadli at gmx dot de
Is there a reason, why this fix still hasn't been implemented?

I'd like to see this bug fixed in PHP 5.5
 [2013-06-24 18:12 UTC] felipe@php.net
-Assigned To: colder +Assigned To: dsp
 [2013-06-24 18:12 UTC] felipe@php.net
David, what about this change on 5.5?
 [2013-06-25 05:18 UTC] laruence@php.net
hmm, thanks for the reminding, I'd like to see this could happen in 5.5

@dsp, what do you think?
 [2013-07-22 05:47 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=83ced9124ea0f7be4950b8267b518b05c70323fe
Log: Fix bug #61697 - spl_autoload_functions returns lambda functions incorrectly
 [2013-07-22 05:47 UTC] stas@php.net
-Status: Assigned +Status: Closed
 [2013-07-23 17:53 UTC] aharvey@php.net
-Status: Closed +Status: Re-Opened -Assigned To: dsp +Assigned To: aharvey
 [2013-07-23 17:53 UTC] aharvey@php.net
It looks like the fix for this has caused a build failure (Linux, armhf):

adam@tf101:~/trees/php-src/5.5$ make
/bin/bash /home/adam/trees/php-src/5.5/libtool --silent --preserve-dup-deps --
mode=compile cc  -Iext/spl/ -I/home/adam/trees/php-src/5.5/ext/spl/ -
DPHP_ATOM_INC -I/home/adam/trees/php-src/5.5/include -I/home/adam/trees/php-
src/5.5/main -I/home/adam/trees/php-src/5.5 -I/home/adam/trees/php-
src/5.5/ext/date/lib -I/home/adam/trees/php-src/5.5/ext/ereg/regex -
I/home/adam/trees/php-src/5.5/TSRM -I/home/adam/trees/php-src/5.5/Zend    -g -O2 
-fvisibility=hidden  -c /home/adam/trees/php-src/5.5/ext/spl/php_spl.c -o 
ext/spl/php_spl.lo 
/home/adam/trees/php-src/5.5/ext/spl/php_spl.c: In function 
‘zif_spl_autoload_functions’:
/home/adam/trees/php-src/5.5/ext/spl/php_spl.c:747:81: error: macro "strncmp" 
requires 3 arguments, but only 2 given
make: *** [ext/spl/php_spl.lo] Error 1

Investigating, but I may kick this back to Stas or Laruence if needed.
 [2013-07-23 18:46 UTC] aharvey@php.net
-Status: Re-Opened +Status: Closed
 [2013-07-23 18:46 UTC] aharvey@php.net
Fixed by expanding the ZEND_STRL macro call, since strncmp() is itself a macro on 
armhf Linux: http://git.php.net/?p=php-
src.git;a=commitdiff;h=f9000fde98195844b4d1c1d6209f9796da3ebee8
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=83ced9124ea0f7be4950b8267b518b05c70323fe
Log: Fix bug #61697 - spl_autoload_functions returns lambda functions incorrectly
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC