Skip to content

Commit cfc6c4d

Browse files
committed
Fixed Bug #75212 php_value acts like php_admin_value
1 parent 084e340 commit cfc6c4d

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

sapi/fpm/fpm/fpm_php.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_
3838
|| ini_entry->on_modify(ini_entry, duplicate,
3939
ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage) == SUCCESS) {
4040
ini_entry->value = duplicate;
41-
ini_entry->modifiable = mode;
41+
/* when mode == ZEND_INI_USER keep unchanged to allow ZEND_INI_PERDIR (.user.ini) */
42+
if (mode == ZEND_INI_SYSTEM) {
43+
ini_entry->modifiable = mode;
44+
}
4245
} else {
4346
zend_string_release(duplicate);
4447
}

sapi/fpm/tests/023-bug72212.phpt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
--TEST--
2+
FPM: bug #75212 php_value acts like php_admin_value
3+
--SKIPIF--
4+
<?php include "skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
include "include.inc";
9+
10+
$logfile = __DIR__.'/php-fpm.log.tmp';
11+
$srcfile = __DIR__.'/bug75212.php';
12+
$inifile = __DIR__.'/.user.ini';
13+
$port = 9000+PHP_INT_SIZE;
14+
15+
$cfg = <<<EOT
16+
[global]
17+
error_log = $logfile
18+
[unconfined]
19+
listen = 127.0.0.1:$port
20+
pm = dynamic
21+
pm.max_children = 5
22+
pm.start_servers = 1
23+
pm.min_spare_servers = 1
24+
pm.max_spare_servers = 3
25+
php_admin_value[memory_limit]=32M
26+
php_value[date.timezone]=Europe/London
27+
EOT;
28+
29+
$code = <<<EOT
30+
<?php
31+
echo "Test Start\n";
32+
var_dump(ini_get('memory_limit'), ini_get('date.timezone'));
33+
echo "Test End\n";
34+
EOT;
35+
file_put_contents($srcfile, $code);
36+
37+
$ini = <<<EOT
38+
memory_limit=64M
39+
date.timezone=Europe/Paris
40+
41+
EOT;
42+
file_put_contents($inifile, $ini);
43+
44+
$fpm = run_fpm($cfg, $tail);
45+
if (is_resource($fpm)) {
46+
fpm_display_log($tail, 2);
47+
try {
48+
$req = run_request('127.0.0.1', $port, $srcfile);
49+
echo strstr($req, "Test Start");
50+
echo "Request ok\n";
51+
} catch (Exception $e) {
52+
echo "Request error\n";
53+
}
54+
proc_terminate($fpm);
55+
fpm_display_log($tail, -1);
56+
fclose($tail);
57+
proc_close($fpm);
58+
}
59+
60+
?>
61+
Done
62+
--EXPECTF--
63+
[%s] NOTICE: fpm is running, pid %d
64+
[%s] NOTICE: ready to handle connections
65+
Test Start
66+
string(3) "32M"
67+
string(12) "Europe/Paris"
68+
Test End
69+
70+
Request ok
71+
[%s] NOTICE: Terminating ...
72+
[%s] NOTICE: exiting, bye-bye!
73+
Done
74+
--CLEAN--
75+
<?php
76+
$logfile = __DIR__.'/php-fpm.log.tmp';
77+
$srcfile = __DIR__.'/bug75212.php';
78+
$inifile = __DIR__.'/.user.ini';
79+
@unlink($logfile);
80+
@unlink($srcfile);
81+
@unlink($inifile);
82+
?>

sapi/fpm/tests/include.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function run_request($host, $port, $uri='/ping', $query='', $headers=array()) {
127127
'SERVER_NAME' => php_uname('n'),
128128
'SERVER_PROTOCOL' => 'HTTP/1.1',
129129
'CONTENT_TYPE' => '',
130+
'DOCUMENT_ROOT' => __DIR__,
130131
'CONTENT_LENGTH' => 0
131132
), $headers);
132133
return $client->request($params, false)."\n";

0 commit comments

Comments
 (0)