-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-10011 (Trampoline autoloader will get reregistered and cannot …
…be unregistered) There are two issues to resolve: 1. The FCC is not refetch when trying to unregister a trampoline 2. Comparing the function pointer of trampolines is meaningless as they are reallocated, thus we need to compare the name of the function Found while working on GH-8294 Closes GH-10033
- Loading branch information
Showing
3 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--TEST-- | ||
Bug GH-10011 (Trampoline autoloader will get reregistered and cannot be unregistered) | ||
--FILE-- | ||
<?php | ||
|
||
class TrampolineTest { | ||
public function __call(string $name, array $arguments) { | ||
echo 'Trampoline for ', $name, PHP_EOL; | ||
} | ||
} | ||
$o = new TrampolineTest(); | ||
$callback1 = [$o, 'trampoline1']; | ||
$callback2 = [$o, 'trampoline2']; | ||
|
||
spl_autoload_register($callback1); | ||
spl_autoload_register($callback2); | ||
spl_autoload_register($callback1); // 2nd call ignored | ||
|
||
var_dump(spl_autoload_functions()); | ||
|
||
var_dump(class_exists("TestClass", true)); | ||
|
||
echo "Unregister trampoline:\n"; | ||
var_dump(spl_autoload_unregister($callback1)); | ||
var_dump(spl_autoload_unregister($callback1)); | ||
var_dump(spl_autoload_unregister($callback2)); | ||
|
||
var_dump(spl_autoload_functions()); | ||
var_dump(class_exists("TestClass", true)); | ||
?> | ||
--EXPECT-- | ||
array(2) { | ||
[0]=> | ||
array(2) { | ||
[0]=> | ||
object(TrampolineTest)#1 (0) { | ||
} | ||
[1]=> | ||
string(11) "trampoline1" | ||
} | ||
[1]=> | ||
array(2) { | ||
[0]=> | ||
object(TrampolineTest)#1 (0) { | ||
} | ||
[1]=> | ||
string(11) "trampoline2" | ||
} | ||
} | ||
Trampoline for trampoline1 | ||
Trampoline for trampoline2 | ||
bool(false) | ||
Unregister trampoline: | ||
bool(true) | ||
bool(false) | ||
bool(true) | ||
array(0) { | ||
} | ||
bool(false) |