additional fixes
authorMonish Deb <deb.monish@gmail.com>
Wed, 10 Oct 2018 11:55:28 +0000 (17:25 +0530)
committerMonish Deb <deb.monish@gmail.com>
Tue, 21 May 2019 13:43:54 +0000 (19:13 +0530)
CRM/Mailing/BAO/MailingJob.php
CRM/Utils/System/Drupal8.php

index 8f3dff95e2d4caaea06459272b753192ef046f65..1374f0d1cdb03e905afb7c5e272604e14b589f9b 100644 (file)
@@ -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);
     }
 
index 802a7910bf4dd31ab5bb53208fdd1daa14395b45..933379d14f83fb03ee793dd5d9a597380309de91 100644 (file)
@@ -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) {