Fix GH-22118: Compare equivalent fake closures in FCCs#22145
Fix GH-22118: Compare equivalent fake closures in FCCs#22145prateekbhujel wants to merge 1 commit into
Conversation
Girgias
left a comment
There was a problem hiding this comment.
IMO this should be fixed in zend_fcc_equals() as this same issue would crop up if trying to register and unregister an autoloader using a FCC.
aa37b64 to
7c2e35c
Compare
|
Sorry, you’re right, this was too narrowly placed before. I moved the fake-Closure comparison into I pushed the updated branch and ran the focused tick + SPL autoload tests locally. |
Girgias
left a comment
There was a problem hiding this comment.
Trampoline test and this needs to be backported to PHP 8.4 rather than 8.5 as this issue has existed for longer.
7c2e35c to
b49ce7c
Compare
| ZVAL_OBJ(&closure_zv1, closure1); | ||
| ZVAL_OBJ(&closure_zv2, closure2); | ||
|
|
||
| return zend_compare_objects(&closure_zv1, &closure_zv2) == 0; |
There was a problem hiding this comment.
@TimWolla is this the best way to compare two closures objects?
First-class method callable syntax creates a fresh fake Closure object for each expression. Some callback comparisons were still treating Closure-backed callables by object identity, so equivalent fake Closures could fail to unregister.
Move fake-Closure equivalence into
zend_fcc_equals()so FCC users get the same comparison behavior, and reuse the same helper for SPL autoload's stored callback comparison. The regression coverage includes both a normal first-class method callable and a trampoline callable produced through__call().Fixes GH-22118.
Tests:
sapi/cli/php run-tests.php -q -p sapi/cli/php ext/standard/tests/general_functions/gh22118.phpt ext/spl/tests/gh22118.phpt ext/spl/tests/gh10011.phpt ext/spl/tests/spl_autoload_013.phpt ext/spl/tests/spl_autoload_014.phpt ext/spl/tests/bug75049.phpt ext/spl/tests/spl_autoload_unregister_without_registrations.phpt ext/standard/tests/general_functions/bug66094.phpt