minor #29041 Fix ini_get() for boolean values (deguif)
This PR was merged into the 3.4 branch.
Discussion
----------
Fix ini_get() for boolean values
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
This follows #29020 for branch 3.4
Commits
-------
65b34cb53c
Fix ini_get() for boolean values
This commit is contained in:
commit
6cfd3de7bf
@ -63,7 +63,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
|
||||
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
|
||||
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
|
||||
}
|
||||
if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
|
||||
if (extension_loaded('openssl') && filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN) && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
|
||||
$remoteZip = "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip";
|
||||
$remoteZipStream = @fopen($remoteZip, 'rb');
|
||||
if (!$remoteZipStream) {
|
||||
@ -214,7 +214,7 @@ if ($components) {
|
||||
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
|
||||
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
|
||||
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
|
||||
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
|
||||
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
|
||||
$exit = $procStatus;
|
||||
echo "\033[41mKO\033[0m $component\n\n";
|
||||
} else {
|
||||
|
@ -84,8 +84,8 @@ EOT
|
||||
array('Architecture', (PHP_INT_SIZE * 8).' bits'),
|
||||
array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'),
|
||||
array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'),
|
||||
array('OPcache', \extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'),
|
||||
array('APCu', \extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'),
|
||||
array('OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
|
||||
array('APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
|
||||
array('Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'),
|
||||
);
|
||||
|
||||
|
@ -117,7 +117,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
|
||||
}
|
||||
|
||||
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
|
||||
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
$apcu->setLogger(new NullLogger());
|
||||
} elseif (null !== $logger) {
|
||||
$apcu->setLogger($logger);
|
||||
|
@ -40,7 +40,7 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->pool = $fallbackPool;
|
||||
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
|
||||
$this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
|
||||
$this->createCacheItem = \Closure::bind(
|
||||
function ($key, $value, $isHit) {
|
||||
$item = new CacheItem();
|
||||
@ -68,7 +68,7 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl
|
||||
public static function create($file, CacheItemPoolInterface $fallbackPool)
|
||||
{
|
||||
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
|
||||
if ((\PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || \defined('HHVM_VERSION')) {
|
||||
if ((\PHP_VERSION_ID >= 70000 && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) || \defined('HHVM_VERSION')) {
|
||||
if (!$fallbackPool instanceof AdapterInterface) {
|
||||
$fallbackPool = new ProxyAdapter($fallbackPool);
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
|
||||
|
||||
$e = new \Exception();
|
||||
$this->includeHandler = function () use ($e) { throw $e; };
|
||||
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
|
||||
$this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInt
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->pool = $fallbackPool;
|
||||
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
|
||||
$this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,7 +51,7 @@ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInt
|
||||
public static function create($file, CacheInterface $fallbackPool)
|
||||
{
|
||||
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
|
||||
if ((\PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || \defined('HHVM_VERSION')) {
|
||||
if ((\PHP_VERSION_ID >= 70000 && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) || \defined('HHVM_VERSION')) {
|
||||
return new static($file, $fallbackPool);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,6 @@ class PhpFilesCache extends AbstractCache implements PruneableInterface
|
||||
|
||||
$e = new \Exception();
|
||||
$this->includeHandler = function () use ($e) { throw $e; };
|
||||
$this->zendDetectUnicode = ini_get('zend.detect_unicode');
|
||||
$this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ class ApcuAdapterTest extends AdapterTestCase
|
||||
|
||||
public function createCachePool($defaultLifetime = 0)
|
||||
{
|
||||
if (!\function_exists('apcu_fetch') || !ini_get('apc.enabled')) {
|
||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
$this->markTestSkipped('APCu extension is required.');
|
||||
}
|
||||
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
if ('testWithCliSapi' !== $this->getName()) {
|
||||
$this->markTestSkipped('apc.enable_cli=1 is required.');
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
'localhost',
|
||||
11222,
|
||||
);
|
||||
if (ini_get('memcached.use_sasl')) {
|
||||
if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
yield array(
|
||||
'memcached://user:password@127.0.0.1?weight=50',
|
||||
'127.0.0.1',
|
||||
@ -154,7 +154,7 @@ class MemcachedAdapterTest extends AdapterTestCase
|
||||
'/var/local/run/memcached.socket',
|
||||
0,
|
||||
);
|
||||
if (ini_get('memcached.use_sasl')) {
|
||||
if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
yield array(
|
||||
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
||||
'/var/local/run/memcached.socket',
|
||||
|
@ -23,7 +23,7 @@ class ApcuCacheTest extends CacheTestCase
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
if (!\function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli'))) {
|
||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||
$this->markTestSkipped('APCu extension is required.');
|
||||
}
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
|
@ -146,7 +146,7 @@ class MemcachedCacheTest extends CacheTestCase
|
||||
'localhost',
|
||||
11222,
|
||||
);
|
||||
if (ini_get('memcached.use_sasl')) {
|
||||
if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
yield array(
|
||||
'memcached://user:password@127.0.0.1?weight=50',
|
||||
'127.0.0.1',
|
||||
@ -163,7 +163,7 @@ class MemcachedCacheTest extends CacheTestCase
|
||||
'/var/local/run/memcached.socket',
|
||||
0,
|
||||
);
|
||||
if (ini_get('memcached.use_sasl')) {
|
||||
if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
yield array(
|
||||
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
||||
'/var/local/run/memcached.socket',
|
||||
|
@ -23,7 +23,7 @@ trait ApcuTrait
|
||||
{
|
||||
public static function isSupported()
|
||||
{
|
||||
return \function_exists('apcu_fetch') && ini_get('apc.enabled');
|
||||
return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
private function init($namespace, $defaultLifetime, $version)
|
||||
@ -75,7 +75,7 @@ trait ApcuTrait
|
||||
*/
|
||||
protected function doClear($namespace)
|
||||
{
|
||||
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || ini_get('apc.enable_cli'))
|
||||
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))
|
||||
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY))
|
||||
: apcu_clear_cache();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ trait PhpFilesTrait
|
||||
|
||||
public static function isSupported()
|
||||
{
|
||||
return \function_exists('opcache_invalidate') && ini_get('opcache.enable');
|
||||
return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ trait PhpFilesTrait
|
||||
{
|
||||
$time = time();
|
||||
$pruned = true;
|
||||
$allowCompile = 'cli' !== \PHP_SAPI || ini_get('opcache.enable_cli');
|
||||
$allowCompile = 'cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
set_error_handler($this->includeHandler);
|
||||
try {
|
||||
@ -119,7 +119,7 @@ trait PhpFilesTrait
|
||||
{
|
||||
$ok = true;
|
||||
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
|
||||
$allowCompile = 'cli' !== \PHP_SAPI || ini_get('opcache.enable_cli');
|
||||
$allowCompile = 'cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
if (null === $value || \is_object($value)) {
|
||||
|
@ -131,7 +131,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
|
||||
if (\PHP_VERSION_ID < 70000) {
|
||||
$this->prefetchData = null;
|
||||
}
|
||||
if (!headers_sent() && ini_get('session.use_cookies')) {
|
||||
if (!headers_sent() && filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
if (!$this->sessionName) {
|
||||
throw new \LogicException(sprintf('Session name cannot be empty, did you forget to call "parent::open()" in "%s"?.', \get_class($this)));
|
||||
}
|
||||
@ -159,7 +159,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
|
||||
header($h, false);
|
||||
}
|
||||
} else {
|
||||
setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
|
||||
setcookie($this->sessionName, '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), filter_var(ini_get('session.cookie_secure'), FILTER_VALIDATE_BOOLEAN), filter_var(ini_get('session.cookie_httponly'), FILTER_VALIDATE_BOOLEAN));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
||||
throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
|
||||
}
|
||||
|
||||
if (!ini_get('session.use_strict_mode') && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
|
||||
if (!filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
|
||||
// In strict mode, session fixation is not possible: new sessions always start with a unique
|
||||
// random id, so that concurrency is not possible and this code path can be skipped.
|
||||
// Exclusive-reading of non-existent rows does not block, so we need to do an insert to block
|
||||
|
@ -137,7 +137,7 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
throw new \RuntimeException('Failed to start the session: already started by PHP.');
|
||||
}
|
||||
|
||||
if (ini_get('session.use_cookies') && headers_sent($file, $line)) {
|
||||
if (filter_var(ini_get('session.use_cookies'), FILTER_VALIDATE_BOOLEAN) && headers_sent($file, $line)) {
|
||||
throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line));
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ error_reporting(-1);
|
||||
ini_set('html_errors', 0);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
if (ini_get('xdebug.default_enable')) {
|
||||
if (filter_var(ini_get('xdebug.default_enable'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
xdebug_disable();
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class PdoSessionHandlerTest extends TestCase
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289');
|
||||
}
|
||||
if (ini_get('session.use_strict_mode')) {
|
||||
if (filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
$this->markTestSkipped('Strict mode needs no locking for new sessions.');
|
||||
}
|
||||
|
||||
|
@ -910,7 +910,7 @@ class PropertyAccessor implements PropertyAccessorInterface
|
||||
}
|
||||
|
||||
$apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version);
|
||||
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
$apcu->setLogger(new NullLogger());
|
||||
} elseif (null !== $logger) {
|
||||
$apcu->setLogger($logger);
|
||||
|
Reference in New Issue
Block a user