CRM-19301 fix dashboard upgrade for multilingual sites
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 2 Sep 2016 08:17:32 +0000 (18:17 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 4 Sep 2016 05:45:29 +0000 (15:45 +1000)
CRM/Core/BAO/SchemaHandler.php
CRM/Upgrade/Incremental/php/FourSeven.php

index e68007d18af98212992d74071baf1cca71401045..5bb971ef05fb831a40685db308387b619e9633fb 100644 (file)
@@ -370,11 +370,18 @@ ALTER TABLE {$tableName}
   /**
    * @param string $tableName
    * @param string $columnName
+   * @param bool $l10n
+   *
    */
-  public static function dropColumn($tableName, $columnName) {
+  public static function dropColumn($tableName, $columnName, $l10n = FALSE) {
     if (self::checkIfFieldExists($tableName, $columnName)) {
       $sql = "ALTER TABLE $tableName DROP COLUMN $columnName";
-      CRM_Core_DAO::executeQuery($sql);
+      if ($l10n) {
+        CRM_Core_DAO::executeQuery($sql);
+      }
+      else {
+        CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE);
+      }
     }
   }
 
index 973c155d216803b213fcc4dc63741370d586982b..ef1ffa03c37ecefbabe55dec6be291d9cec59d00 100644 (file)
@@ -786,6 +786,8 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
       CRM_Core_DAO::executeQuery('DELETE c1 FROM civicrm_dashboard_contact c1, civicrm_dashboard_contact c2 WHERE c1.contact_id = c2.contact_id AND c1.dashboard_id = c2.dashboard_id AND c1.id > c2.id');
       CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_dashboard_contact ADD UNIQUE INDEX index_dashboard_id_contact_id (dashboard_id, contact_id);');
     }
+    $domain = new CRM_Core_DAO_Domain();
+    $domain->find(TRUE);
     CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'content');
     CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'is_minimized');
     CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard_contact', 'is_fullscreen');
@@ -794,6 +796,10 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
     CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'is_minimized');
     CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'column_no');
     CRM_Core_BAO_SchemaHandler::dropColumn('civicrm_dashboard', 'weight');
+    if ($domain->locales) {
+      $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
+      CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL);
+    }
 
     CRM_Core_DAO::executeQuery('UPDATE civicrm_dashboard SET url = REPLACE(url, "&snippet=5", ""), fullscreen_url = REPLACE(fullscreen_url, "&snippet=5", "")');