mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
* opcache: Do not emit “temporary enabling” message when OPcache is already active An easy way to accidentally enable OPcache “temporarily” is by using `php_admin_value[opcache.enable]=1` within a FPM pool’s configuration, since the `php_admin_value` settings mostly behave like settings in php.ini, with many OPcache INI settings being a notable exception. As long as OPcache is already enabled within php.ini (or simply by default), emitting a warning for `php_admin_value[opcache.enable]=1` or similar is going to be confusing, since is not actually temporarily enabling anything. A follow-up commit will also try to detect this kind of incorrect configuration and try to provide better advice for cases where OPcache is actually not yet enabled. * opcache: Improve error message when OPcache is enabled dynamically The error message will now advice on the `php_admin_value[opcache.enable]=1` mistake. It will also send the message to OPcache’s logging facility instead of the regular error handling logic during startup so that it will not be made available to `error_get_last()`, since it is related to a specific request and thus not actionable by a script either. php/php-src#19146 made a related change to `opcache.memory_consumption`. * opcache: Fix typo in warning message * opcache: Use more formal language in warning message
50 lines
1019 B
PHP
50 lines
1019 B
PHP
--TEST--
|
|
Setting opcache.enable via php_admin_value fails gracefully
|
|
--SKIPIF--
|
|
<?php include "skipif.inc"; ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once "tester.inc";
|
|
|
|
$cfg = <<<EOT
|
|
[global]
|
|
error_log = {{FILE:LOG}}
|
|
[unconfined]
|
|
listen = {{ADDR}}
|
|
pm = static
|
|
pm.max_children = 1
|
|
catch_workers_output = yes
|
|
php_admin_value[opcache.enable] = On
|
|
php_admin_flag[display_errors] = On
|
|
php_admin_flag[display_startup_errors] = On
|
|
php_admin_flag[log_errors] = On
|
|
EOT;
|
|
|
|
$code = <<<EOT
|
|
<?php
|
|
var_dump(error_get_last());
|
|
EOT;
|
|
|
|
$tester = new FPM\Tester($cfg, $code);
|
|
$tester->start(iniEntries: [
|
|
'opcache.enable' => '0',
|
|
'opcache.log_verbosity_level' => '2',
|
|
]);
|
|
$tester->expectLogStartNotices();
|
|
$tester->expectLogPattern("/Zend OPcache can't be temporarily enabled. Are you using php_admin_value\\[opcache.enable\\]=1 in an individual pool's configuration?/");
|
|
echo $tester
|
|
->request()
|
|
->getBody();
|
|
$tester->terminate();
|
|
$tester->close();
|
|
|
|
?>
|
|
--EXPECT--
|
|
NULL
|
|
--CLEAN--
|
|
<?php
|
|
require_once "tester.inc";
|
|
FPM\Tester::clean();
|
|
?>
|