From ebc5631d4e6e97d0ab3ca10d8efad4ba03cdb4a4 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 17 Apr 2023 17:09:33 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06172=20\utils::DoPostRequest=20:=20crash?= =?UTF-8?q?=20if=20curl=20php=20ext=20not=20available=20First=20commit=20w?= =?UTF-8?q?as=20made=20in=203fc663a=20but=20I=20forgot=20to=20throw=20an?= =?UTF-8?q?=20exception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 64ba0abc6..f47114a5b 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -20,7 +20,6 @@ use Combodo\iTop\Application\Helper\Session; use Combodo\iTop\Application\UI\Base\iUIBlock; use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock; -use Combodo\iTop\Core\MetaModel\FriendlyNameType; use ScssPhp\ScssPhp\Compiler; use ScssPhp\ScssPhp\OutputStyle; use ScssPhp\ScssPhp\ValueConverter; @@ -1863,14 +1862,20 @@ SQL; * have precedence over the default ones. Example: CURLOPT_SSLVERSION => CURL_SSLVERSION_SSLv3 * * @return string The result of the POST request + * * @throws Exception with a specific error message depending on the cause + * @throws ApplicationException if CURL PHP extension isn't available * * @noinspection PhpComposerExtensionStubsInspection we don't want the "white screen of death" on production (N°6146) * - * @since 3.1.0 N°6172 as curl ext is now mandatory, removes the extension detection + fallback + * @since 3.1.0 N°6172 as curl ext is now mandatory, method will crash with a ApplicationException this PHP extension isn't available */ public static function DoPostRequest($sUrl, $aData, $sOptionnalHeaders = null, &$aResponseHeaders = null, $aCurlOptions = array()) { + if (false === function_exists('curl_init')) { + throw new ApplicationException('\utils::DoPostRequest method called whereas the CURL PHP extension isn\'t available !'); + } + // CURL PHP extension is mandatory since 3.1.0 (N°5270) // it provides a greater control over the various HTTP/SSL options // For instance fopen does not allow to work around the bug: http://stackoverflow.com/questions/18191672/php-curl-ssl-routinesssl23-get-server-helloreason1112