projects
/
civicrm-core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d381a19
)
dev/core#4756 check Drupal container available to check ip address
author
BW
<ufundo@gmail.com>
Tue, 7 Nov 2023 15:17:02 +0000
(15:17 +0000)
committer
BW
<ufundo@gmail.com>
Tue, 7 Nov 2023 15:22:43 +0000
(15:22 +0000)
CRM/Utils/System/Drupal8.php
patch
|
blob
|
blame
|
history
diff --git
a/CRM/Utils/System/Drupal8.php
b/CRM/Utils/System/Drupal8.php
index 2ddb21bb5009b5b457d0a629739cf0cdc292c032..73cd9a270a121021be706ff2988dfa2cee34e081 100644
(file)
--- 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();
}
/**