Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04f5cea

Browse files
committed
Fix ini_get() for boolean values
1 parent 63c74f7 commit 04f5cea

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
6363
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
6464
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
6565
}
66-
if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
66+
if (extension_loaded('openssl') && filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN) && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
6767
$remoteZip = "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip";
6868
$remoteZipStream = @fopen($remoteZip, 'rb');
6969
if (!$remoteZipStream) {
@@ -214,7 +214,7 @@ if ($components) {
214214
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
215215
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
216216
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
217-
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
217+
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
218218
$exit = $procStatus;
219219
echo "\033[41mKO\033[0m $component\n\n";
220220
} else {

src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8484
array('Architecture', (PHP_INT_SIZE * 8).' bits'),
8585
array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'),
8686
array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'),
87-
array('OPcache', \extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'),
88-
array('APCu', \extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'),
87+
array('OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
88+
array('APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
8989
array('Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'),
9090
);
9191

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
117117
}
118118

119119
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
120-
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
120+
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
121121
$apcu->setLogger(new NullLogger());
122122
} elseif (null !== $logger) {
123123
$apcu->setLogger($logger);

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function ($key, $value, $isHit) {
6868
public static function create($file, CacheItemPoolInterface $fallbackPool)
6969
{
7070
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
71-
if ((\PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || \defined('HHVM_VERSION')) {
71+
if ((\PHP_VERSION_ID >= 70000 && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) || \defined('HHVM_VERSION')) {
7272
if (!$fallbackPool instanceof AdapterInterface) {
7373
$fallbackPool = new ProxyAdapter($fallbackPool);
7474
}

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct($file, CacheInterface $fallbackPool)
5151
public static function create($file, CacheInterface $fallbackPool)
5252
{
5353
// Shared memory is available in PHP 7.0+ with OPCache enabled and in HHVM
54-
if ((\PHP_VERSION_ID >= 70000 && ini_get('opcache.enable')) || \defined('HHVM_VERSION')) {
54+
if ((\PHP_VERSION_ID >= 70000 && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) || \defined('HHVM_VERSION')) {
5555
return new static($file, $fallbackPool);
5656
}
5757

src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class ApcuAdapterTest extends AdapterTestCase
2424

2525
public function createCachePool($defaultLifetime = 0)
2626
{
27-
if (!\function_exists('apcu_fetch') || !ini_get('apc.enabled')) {
27+
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) {
2828
$this->markTestSkipped('APCu extension is required.');
2929
}
30-
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
30+
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
3131
if ('testWithCliSapi' !== $this->getName()) {
3232
$this->markTestSkipped('apc.enable_cli=1 is required.');
3333
}

src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ApcuCacheTest extends CacheTestCase
2323

2424
public function createSimpleCache($defaultLifetime = 0)
2525
{
26-
if (!\function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli'))) {
26+
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))) {
2727
$this->markTestSkipped('APCu extension is required.');
2828
}
2929
if ('\\' === \DIRECTORY_SEPARATOR) {

src/Symfony/Component/Cache/Traits/ApcuTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait ApcuTrait
2323
{
2424
public static function isSupported()
2525
{
26-
return \function_exists('apcu_fetch') && ini_get('apc.enabled');
26+
return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN);
2727
}
2828

2929
private function init($namespace, $defaultLifetime, $version)
@@ -75,7 +75,7 @@ protected function doHave($id)
7575
*/
7676
protected function doClear($namespace)
7777
{
78-
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || ini_get('apc.enable_cli'))
78+
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))
7979
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY))
8080
: apcu_clear_cache();
8181
}

src/Symfony/Component/Cache/Traits/PhpFilesTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ trait PhpFilesTrait
3030

3131
public static function isSupported()
3232
{
33-
return \function_exists('opcache_invalidate') && ini_get('opcache.enable');
33+
return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN);
3434
}
3535

3636
/**
@@ -40,7 +40,7 @@ public function prune()
4040
{
4141
$time = time();
4242
$pruned = true;
43-
$allowCompile = 'cli' !== \PHP_SAPI || ini_get('opcache.enable_cli');
43+
$allowCompile = 'cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN);
4444

4545
set_error_handler($this->includeHandler);
4646
try {
@@ -119,7 +119,7 @@ protected function doSave(array $values, $lifetime)
119119
{
120120
$ok = true;
121121
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
122-
$allowCompile = 'cli' !== \PHP_SAPI || ini_get('opcache.enable_cli');
122+
$allowCompile = 'cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN);
123123

124124
foreach ($values as $key => $value) {
125125
if (null === $value || \is_object($value)) {

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ public static function createCache($namespace, $defaultLifetime, $version, Logge
910910
}
911911

912912
$apcu = new ApcuAdapter($namespace, $defaultLifetime / 5, $version);
913-
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
913+
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
914914
$apcu->setLogger(new NullLogger());
915915
} elseif (null !== $logger) {
916916
$apcu->setLogger($logger);

0 commit comments

Comments
 (0)