AllCoreTables - Fix getClassForTable in multilingual databases
authorColeman Watts <coleman@civicrm.org>
Wed, 24 Nov 2021 02:25:58 +0000 (21:25 -0500)
committerColeman Watts <coleman@civicrm.org>
Wed, 24 Nov 2021 02:25:58 +0000 (21:25 -0500)
CRM/Core/DAO/AllCoreTables.php

index febcb374a83cf9c00cea933e419b1fb693b5bbb3..670ce3e06ebbdd4d483862950f68f640bb78bfd9 100644 (file)
@@ -364,6 +364,11 @@ class CRM_Core_DAO_AllCoreTables {
    */
   public static function getEntityNameForTable(string $tableName) {
     self::init();
+    // CRM-19677: on multilingual setup, trim locale from $tableName to fetch class name
+    if (CRM_Core_I18n::isMultilingual()) {
+      global $dbLocale;
+      $tableName = str_replace($dbLocale, '', $tableName);
+    }
     $matches = CRM_Utils_Array::findAll(self::$entityTypes, ['table' => $tableName]);
     return $matches ? $matches[0]['name'] : NULL;
   }