Skip to content

Commit c776f79

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
2 parents a025e6c + 0217be4 commit c776f79

File tree

5 files changed

+71
-5
lines changed

5 files changed

+71
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ PHP NEWS
1111
- Fiber:
1212
. Fixed bug GH-11121 (ReflectionFiber segfault). (danog, trowski, bwoebi)
1313

14+
- FPM:
15+
. Fixed bug GH-12232 (FPM: segfault dynamically loading extension without
16+
opcache). (Jakub Zelenka)
17+
1418
- Opcache:
1519
. Added warning when JIT cannot be enabled. (danog)
1620
. Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since

Zend/zend_ini.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
217217
* lead to death.
218218
*/
219219
if (directives != EG(ini_directives)) {
220-
ZEND_ASSERT(module_type == MODULE_TEMPORARY);
221220
directives = EG(ini_directives);
222221
} else {
223222
ZEND_ASSERT(module_type == MODULE_PERSISTENT);

sapi/fpm/fpm/fpm_php.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
8787

8888
if (!strcmp(name, "extension") && *value) {
8989
zval zv;
90+
zend_interned_strings_switch_storage(0);
9091
php_dl(value, MODULE_PERSISTENT, &zv, 1);
92+
zend_interned_strings_switch_storage(1);
9193
return Z_TYPE(zv) == IS_TRUE;
9294
}
9395

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
FPM: gh12232 - loading shared ext in FPM config
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc";
6+
FPM\Tester::skipIfSharedExtensionNotFound('dl_test');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require_once "tester.inc";
12+
13+
$cfg = <<<EOT
14+
[global]
15+
error_log = {{FILE:LOG}}
16+
[unconfined]
17+
listen = {{ADDR}}
18+
pm = static
19+
pm.max_children = 1
20+
pm.status_path = /status
21+
catch_workers_output = yes
22+
php_admin_value[extension] = dl_test
23+
EOT;
24+
25+
$code = <<<EOT
26+
<?php
27+
var_dump(extension_loaded('dl_test'));
28+
var_dump(ini_get('dl_test.string'));
29+
ini_set('dl_test.string', 'test');
30+
var_dump(ini_get('dl_test.string'));
31+
EOT;
32+
33+
$tester = new FPM\Tester($cfg, $code);
34+
$tester->start();
35+
$tester->expectLogStartNotices();
36+
$tester->request()->expectBody(['bool(true)', 'string(5) "hello"', 'string(4) "test"']);
37+
$tester->request()->expectBody(['bool(true)', 'string(5) "hello"', 'string(4) "test"']);
38+
$tester->terminate();
39+
$tester->expectLogTerminatingNotices();
40+
$tester->close();
41+
42+
?>
43+
Done
44+
--EXPECT--
45+
Done
46+
--CLEAN--
47+
<?php
48+
require_once "tester.inc";
49+
FPM\Tester::clean();
50+
?>
51+
<?php

sapi/fpm/tests/tester.inc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,23 @@ class Tester
331331
}
332332

333333
/**
334-
* Skip if posix extension not loaded.
334+
* Skip if shared extension is not available in extension directory.
335335
*/
336-
static public function skipIfUserDoesNotExist($userName)
336+
static public function skipIfSharedExtensionNotFound($extensionName)
337337
{
338+
$soPath = ini_get('extension_dir') . '/' . $extensionName . '.so';
339+
if ( ! file_exists($soPath)) {
340+
die("skip $extensionName extension not present in extension_dir");
341+
}
342+
}
343+
344+
/**
345+
* Skip if posix extension not loaded.
346+
*/
347+
static public function skipIfUserDoesNotExist($userName) {
338348
self::skipIfPosixNotLoaded();
339-
if (posix_getpwnam($userName) === false) {
340-
die("skip user $userName does not exist");
349+
if ( posix_getpwnam( $userName ) === false ) {
350+
die( "skip user $userName does not exist" );
341351
}
342352
}
343353

0 commit comments

Comments
 (0)