From: BW Date: Tue, 7 Nov 2023 15:17:02 +0000 (+0000) Subject: dev/core#4756 check Drupal container available to check ip address X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=997d471eec83ab5e28f7714e547c3950ddaae945;p=civicrm-core.git dev/core#4756 check Drupal container available to check ip address --- diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 2ddb21bb50..73cd9a270a 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -944,7 +944,11 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { * @inheritdoc */ public function ipAddress():?string { - return class_exists('Drupal') ? \Drupal::request()->getClientIp() : ($_SERVER['REMOTE_ADDR'] ?? NULL); + // dev/core#4756 fallback if checking before CMS bootstrap + if (!class_exists('Drupal') || !\Drupal::hasContainer()) { + return ($_SERVER['REMOTE_ADDR'] ?? NULL); + } + return \Drupal::request()->getClientIp(); } /**