diff --git a/mailpoet/lib/API/JSON/API.php b/mailpoet/lib/API/JSON/API.php index 2704f890d5..c829434d9d 100644 --- a/mailpoet/lib/API/JSON/API.php +++ b/mailpoet/lib/API/JSON/API.php @@ -281,7 +281,9 @@ class API { private function logError(Throwable $e): void { // logging to the php log - error_log((string)$e); // phpcs:ignore Squiz.PHP.DiscouragedFunctions + if (function_exists('error_log')) { + error_log((string)$e); // phpcs:ignore Squiz.PHP.DiscouragedFunctions + } // logging to the MailPoet table $this->loggerFactory->getLogger(LoggerFactory::TOPIC_API)->warning($e->getMessage(), [ 'requestMethod' => $this->requestMethod, diff --git a/mailpoet/lib/API/REST/API.php b/mailpoet/lib/API/REST/API.php index 9cb738a69d..a6cfd69100 100644 --- a/mailpoet/lib/API/REST/API.php +++ b/mailpoet/lib/API/REST/API.php @@ -83,7 +83,7 @@ class API { ? new ErrorResponse($e->getStatusCode(), $e->getMessage(), $e->getErrorCode(), $e->getErrors()) : new ErrorResponse(500, __('An unknown error occurred.', 'mailpoet'), 'mailpoet_automation_unknown_error'); - if ($response->get_status() >= 500) { + if ($response->get_status() >= 500 && function_exists('error_log')) { error_log((string)$e); // phpcs:ignore Squiz.PHP.DiscouragedFunctions } return $response; diff --git a/mailpoet/lib/Config/TranslationUpdater.php b/mailpoet/lib/Config/TranslationUpdater.php index 922caa4d10..e61604b4b7 100644 --- a/mailpoet/lib/Config/TranslationUpdater.php +++ b/mailpoet/lib/Config/TranslationUpdater.php @@ -165,7 +165,9 @@ class TranslationUpdater { if (class_exists(Debugger::class)) { Debugger::log($message, ILogger::ERROR); } - error_log($message); // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged + if (function_exists('error_log')) { + error_log($message); // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged + } } /**