Attempt to fix upgrade and keep activity tab filter settings
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 6 Jun 2016 13:07:44 +0000 (23:07 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 23 Jun 2016 03:27:19 +0000 (13:27 +1000)
CRM/Upgrade/Incremental/php/FourSeven.php

index dc20d254763c8a66779dbb274df7445f7f4ed088..7ec97f95e43acfc70c895204bfb6482a8e298b5d 100644 (file)
@@ -254,11 +254,27 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
 
     // Nav records are expendable. https://forum.civicrm.org/index.php?topic=36933.0
     CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE contact_id IS NOT NULL AND name = "navigation"');
+
+    // Handle Strange activity_tab_filter settings.
+    CRM_Core_DAO::executeQuery('CREATE TABLE civicrm_activity_setting LIKE civicrm_setting');
+    CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_activity_setting DROP INDEX index_group_name');
+    CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_activity_setting DROP COLUMN group_name');
+    CRM_Core_DAO::executeQuery('INSERT INTO civicrm_activity_setting (name, contact_id, domain_id, value)
+     SELECT DISTNCT name, contact_id, domain_id, value
+     FROM civicrm_setting
+     WHERE name = "activity_tab_filter"
+     AND value is not NULL');
     CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE name = "activity_tab_filter"');
 
     CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting DROP INDEX index_group_name');
     CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting DROP COLUMN group_name');
     CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting ADD UNIQUE INDEX index_domain_contact_name (domain_id, contact_id, name)');
+    CRM_Core_DAO::executeQuery('INSERT INTO civicrm_setting (name, contact_id, domain_id, value)
+     SELECT DISTNCT name, contact_id, domain_id, value
+     FROM civicrm_activity_setting
+     WHERE name = "activity_tab_filter"
+     AND value is not NULL');
+    CRM_Core_DAO::executeQuery('DROP TABLE civicrm_activity_setting');
 
     $domainDao = CRM_Core_DAO::executeQuery('SELECT id, config_backend FROM civicrm_domain');
     while ($domainDao->fetch()) {