From 87568e34ea5e3820aad245274836e59460c90673 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 2 Sep 2016 18:17:32 +1000 Subject: [PATCH] CRM-19301 fix dashboard upgrade for multilingual sites --- CRM/Core/BAO/SchemaHandler.php | 11 +++++++++-- CRM/Upgrade/Incremental/php/FourSeven.php | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index e68007d18a..5bb971ef05 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -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); + } } } diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 973c155d21..ef1ffa03c3 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -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", "")'); -- 2.25.1