-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP-8.4: Fix GH-16628: FPM logs are getting corrupted with this log statement Fix GH-16601: Memory leak in Reflection constructors
- Loading branch information
Showing
10 changed files
with
217 additions
and
13 deletions.
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
20 changes: 20 additions & 0 deletions
20
ext/reflection/tests/ReflectionExtension_double_construct.phpt
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,20 @@ | ||
--TEST-- | ||
ReflectionExtension double construct call | ||
--FILE-- | ||
<?php | ||
|
||
$r = new ReflectionExtension('standard'); | ||
var_dump($r); | ||
$r->__construct('standard'); | ||
var_dump($r); | ||
|
||
?> | ||
--EXPECT-- | ||
object(ReflectionExtension)#1 (1) { | ||
["name"]=> | ||
string(8) "standard" | ||
} | ||
object(ReflectionExtension)#1 (1) { | ||
["name"]=> | ||
string(8) "standard" | ||
} |
21 changes: 21 additions & 0 deletions
21
ext/reflection/tests/ReflectionObject_double_construct.phpt
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,21 @@ | ||
--TEST-- | ||
ReflectionObject double construct call | ||
--FILE-- | ||
<?php | ||
|
||
$obj = new stdClass; | ||
$r = new ReflectionObject($obj); | ||
var_dump($r); | ||
$r->__construct($obj); | ||
var_dump($r); | ||
|
||
?> | ||
--EXPECT-- | ||
object(ReflectionObject)#2 (1) { | ||
["name"]=> | ||
string(8) "stdClass" | ||
} | ||
object(ReflectionObject)#2 (1) { | ||
["name"]=> | ||
string(8) "stdClass" | ||
} |
27 changes: 27 additions & 0 deletions
27
ext/reflection/tests/ReflectionParameter_double_construct.phpt
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,27 @@ | ||
--TEST-- | ||
ReflectionParameter double construct call | ||
--FILE-- | ||
<?php | ||
|
||
$closure = function (int $x): void {}; | ||
$r = new ReflectionParameter($closure, 'x'); | ||
var_dump($r); | ||
$r->__construct($closure, 'x'); | ||
var_dump($r); | ||
$r->__construct('ord', 'character'); | ||
var_dump($r); | ||
|
||
?> | ||
--EXPECT-- | ||
object(ReflectionParameter)#2 (1) { | ||
["name"]=> | ||
string(1) "x" | ||
} | ||
object(ReflectionParameter)#2 (1) { | ||
["name"]=> | ||
string(1) "x" | ||
} | ||
object(ReflectionParameter)#2 (1) { | ||
["name"]=> | ||
string(9) "character" | ||
} |
24 changes: 24 additions & 0 deletions
24
ext/reflection/tests/ReflectionProperty_double_construct.phpt
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,24 @@ | ||
--TEST-- | ||
ReflectionProperty double construct call | ||
--FILE-- | ||
<?php | ||
|
||
$r = new ReflectionProperty(Exception::class, 'message'); | ||
var_dump($r); | ||
$r->__construct(Exception::class, 'message'); | ||
var_dump($r); | ||
|
||
?> | ||
--EXPECT-- | ||
object(ReflectionProperty)#1 (2) { | ||
["name"]=> | ||
string(7) "message" | ||
["class"]=> | ||
string(9) "Exception" | ||
} | ||
object(ReflectionProperty)#1 (2) { | ||
["name"]=> | ||
string(7) "message" | ||
["class"]=> | ||
string(9) "Exception" | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,53 @@ | ||
--TEST-- | ||
GH-16628 (FPM logs are getting corrupted with this log statement) | ||
--EXTENSIONS-- | ||
zend_test | ||
--SKIPIF-- | ||
<?php include "skipif.inc"; ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once "tester.inc"; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = {{FILE:LOG}} | ||
log_level = debug | ||
[unconfined] | ||
listen = {{ADDR}} | ||
pm = dynamic | ||
pm.max_children = 5 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 3 | ||
catch_workers_output = yes | ||
decorate_workers_output = no | ||
EOT; | ||
|
||
$code = <<<'EOT' | ||
<?php | ||
for ($i = 1; $i < 100; $i++) { | ||
zend_test_log_err_debug(str_repeat("a", $i)); | ||
} | ||
EOT; | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
$tester->request()->expectEmptyBody(); | ||
for ($i = 1; $i < 100; $i++) { | ||
$tester->expectLogNotice("%sPHP message: " . str_repeat("a", $i)); | ||
} | ||
$tester->terminate(); | ||
$tester->expectLogTerminatingNotices(); | ||
$tester->close(); | ||
|
||
?> | ||
Done | ||
--EXPECT-- | ||
Done | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |