bug #29020 Fix ini_get() for boolean values (deguif)
This PR was merged into the 2.8 branch.
Discussion
----------
Fix ini_get() for boolean values
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Currently setting `false` or `off`, ... value to configure some PHP ini directives will make this evaluated to `true` as this is equal to a non empty string.
Commits
-------
a1538696c3
Fix ini_get() for boolean values
This commit is contained in:
commit
5a2969cf68
@ -19,7 +19,7 @@ class ApcClassLoaderTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) {
|
||||
if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||
$this->markTestSkipped('The apc extension is not enabled.');
|
||||
} else {
|
||||
apcu_clear_cache();
|
||||
@ -28,7 +28,7 @@ class ApcClassLoaderTest extends TestCase
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class LegacyApcUniversalClassLoaderTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
apcu_clear_cache();
|
||||
} else {
|
||||
$this->markTestSkipped('APC is not enabled.');
|
||||
@ -30,7 +30,7 @@ class LegacyApcUniversalClassLoaderTest extends TestCase
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) {
|
||||
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (\function_exists('opcache_invalidate') && ini_get('opcache.enable')) {
|
||||
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
@opcache_invalidate($this->file, true);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Debug
|
||||
if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
|
||||
ini_set('display_errors', 0);
|
||||
ExceptionHandler::register();
|
||||
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
|
||||
} elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
|
||||
// CLI - display errors only if they're not already logged to STDERR
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
@ -63,10 +63,10 @@ class ConfigDataCollector extends DataCollector
|
||||
'php_version' => PHP_VERSION,
|
||||
'xdebug_enabled' => \extension_loaded('xdebug'),
|
||||
'eaccel_enabled' => \extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
|
||||
'apc_enabled' => \extension_loaded('apc') && ini_get('apc.enabled'),
|
||||
'xcache_enabled' => \extension_loaded('xcache') && ini_get('xcache.cacher'),
|
||||
'wincache_enabled' => \extension_loaded('wincache') && ini_get('wincache.ocenabled'),
|
||||
'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
|
||||
'apc_enabled' => \extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN),
|
||||
'xcache_enabled' => \extension_loaded('xcache') && filter_var(ini_get('xcache.cacher'), FILTER_VALIDATE_BOOLEAN),
|
||||
'wincache_enabled' => \extension_loaded('wincache') && filter_var(ini_get('wincache.ocenabled'), FILTER_VALIDATE_BOOLEAN),
|
||||
'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN),
|
||||
'bundles' => array(),
|
||||
'sapi_name' => \PHP_SAPI,
|
||||
);
|
||||
|
@ -45,13 +45,13 @@ class ConfigDataCollectorTest extends TestCase
|
||||
// if else clause because we don't know it
|
||||
if (((\extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
|
||||
||
|
||||
(\extension_loaded('apc') && ini_get('apc.enabled'))
|
||||
(\extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN))
|
||||
||
|
||||
(\extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
|
||||
(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN))
|
||||
||
|
||||
(\extension_loaded('xcache') && ini_get('xcache.cacher'))
|
||||
(\extension_loaded('xcache') && filter_var(ini_get('xcache.cacher'), FILTER_VALIDATE_BOOLEAN))
|
||||
||
|
||||
(\extension_loaded('wincache') && ini_get('wincache.ocenabled')))) {
|
||||
(\extension_loaded('wincache') && filter_var(ini_get('wincache.ocenabled'), FILTER_VALIDATE_BOOLEAN)))) {
|
||||
$this->assertTrue($c->hasAccelerator());
|
||||
} else {
|
||||
$this->assertFalse($c->hasAccelerator());
|
||||
|
@ -22,7 +22,7 @@ class LegacyApcCacheTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!ini_get('apc.enabled') || !ini_get('apc.enable_cli')) {
|
||||
if (!filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
$this->markTestSkipped('APC is not enabled.');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user