From c59c5519048db68e237392b8be767d5618ddfaae Mon Sep 17 00:00:00 2001 From: Monish Deb Date: Wed, 10 Oct 2018 17:25:28 +0530 Subject: [PATCH] additional fixes --- CRM/Mailing/BAO/MailingJob.php | 2 +- CRM/Utils/System/Drupal8.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 8f3dff95e2..1374f0d1cd 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -509,7 +509,7 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) $config = CRM_Core_Config::singleton(); } - if (property_exists($mailing, 'language') && $mailing->language && $mailing->language != 'en_US') { + if (property_exists($mailing, 'language') && $mailing->language && $mailing->language != CRM_Core_I18n::getLocale()) { $swapLang = CRM_Utils_AutoClean::swap('global://dbLocale?getter', 'call://i18n/setLocale', $mailing->language); } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 802a7910bf..933379d14f 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -709,6 +709,11 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return $url; } + // Drupal might not be bootstrapped if being called by the REST API. + if (!class_exists('Drupal')) { + return NULL; + } + $language = $this->getCurrentLanguage(); if (\Drupal::service('module_handler')->moduleExists('language')) { $config = \Drupal::config('language.negotiation')->get('url'); @@ -722,7 +727,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { //url prefix if ($urlType == \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { if (!empty($language)) { - if ($addLanguagePart) { + if ($addLanguagePart && !empty($config['prefixes'][$language])) { $url .= $config['prefixes'][$language] . '/'; } if ($removeLanguagePart) { -- 2.25.1