From 114217c6e3b35653923815786221c94b023c36a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Wed, 31 Oct 2018 09:55:53 +0100 Subject: [PATCH] Fix ini_get() for boolean values --- src/Composer/Autoload/ClassLoader.php | 2 +- src/Composer/Command/DiagnoseCommand.php | 6 +++--- src/Composer/Compiler.php | 2 +- src/Composer/Util/ErrorHandler.php | 2 +- src/Composer/Util/RemoteFilesystem.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index 95f7e0978..fce8549f0 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -279,7 +279,7 @@ class ClassLoader */ public function setApcuPrefix($apcuPrefix) { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; } /** diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 3efb34973..3cb783b3b 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -481,7 +481,7 @@ EOT $errors['iconv_mbstring'] = true; } - if (!ini_get('allow_url_fopen')) { + if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) { $errors['allow_url_fopen'] = true; } @@ -505,7 +505,7 @@ EOT $warnings['openssl_version'] = true; } - if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) { + if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { $warnings['apc_cli'] = true; } @@ -528,7 +528,7 @@ EOT } } - if (ini_get('xdebug.profiler_enabled')) { + if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) { $warnings['xdebug_profile'] = true; } elseif (extension_loaded('xdebug')) { $warnings['xdebug_loaded'] = true; diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index 4064b20b5..27b1f4816 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -255,7 +255,7 @@ class Compiler */ // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264 -if (extension_loaded('apc') && ini_get('apc.enable_cli') && ini_get('apc.cache_by_default')) { +if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) { if (version_compare(phpversion('apc'), '3.0.12', '>=')) { ini_set('apc.cache_by_default', 0); } else { diff --git a/src/Composer/Util/ErrorHandler.php b/src/Composer/Util/ErrorHandler.php index 925cab74c..83e6b5ede 100644 --- a/src/Composer/Util/ErrorHandler.php +++ b/src/Composer/Util/ErrorHandler.php @@ -41,7 +41,7 @@ class ErrorHandler return; } - if (ini_get('xdebug.scream')) { + if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) { $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be". "\na legitimately suppressed error that you were not supposed to see."; } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index def4091a6..39f049cbe 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -364,7 +364,7 @@ class RemoteFilesystem } $result = false; } - if ($errorMessage && !ini_get('allow_url_fopen')) { + if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) { $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')'; } restore_error_handler();