From d1ab9fffd59309b615440323644e9fb9ed2b2166 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 12 Nov 2019 21:38:56 -0800 Subject: [PATCH] (dev/core#1387) FiveTwentyThree - Drop civicrm_domain.config_backend if it snuck in This column was dropped in 4.7.alpha1, but it was still created on new installs, so * Sites originating with 4.7 - 5.22 should have an empty copy of the column today (because it was defined in xml schema - but never used by live code). * Sites originating with <4.7 (and subsequently upgraded) should not have the column today (because FourSeven.php previously dropped it). * Sites originating with <4.7 (and not yet upgraded) should have the column with some data (because FourSeven.php hasn't run yet). * It is unexpected that any site currently on 4.7-5.22 would have any data in that column. Note: `dropColumn` has a built-in guard so it only drops the column if it exists. --- .../Incremental/php/FiveTwentyThree.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FiveTwentyThree.php b/CRM/Upgrade/Incremental/php/FiveTwentyThree.php index ad3344e6ea..943a8c5491 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwentyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveTwentyThree.php @@ -29,6 +29,14 @@ class CRM_Upgrade_Incremental_php_FiveTwentyThree extends CRM_Upgrade_Incrementa // if ($rev == '5.12.34') { // $preUpgradeMessage .= '

' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '

'; // } + if ($rev == '5.23.alpha1' && version_compare($currentVer, '4.7', '>=')) { + if ($this->hasConfigBackendData()) { + $preUpgradeMessage .= '
' . ts("WARNING: The column \"civicrm_domain.config_backend\" is flagged for removal. However, the upgrader has detected data in this copy of \"civicrm_domain.config_backend\". Please report anything you can about the usage of this column. In the mean-time, the data will be preserved.", [ + 1 => 'https://civicrm.org/bug-reporting', + 2 => 'https://lab.civicrm.org/dev/core/issues/1387', + ]); + } + } } /** @@ -75,6 +83,11 @@ class CRM_Upgrade_Incremental_php_FiveTwentyThree extends CRM_Upgrade_Incrementa $this->addTask('Remove Google + location option', 'removeGooglePlusOption'); $this->addTask('dev/mailing#59 Add in IMAP_XOAUTH2 protocol option for mailbox access', 'addXoauth2ProtocolOption'); $this->addTask('dev/translation#34 Fix contact-reference option for Postal Code', 'fixContactRefOptionPostalCode'); + + // (dev/core#1387) This column was dropped in 4.7.alpha1, but it was still created on new installs. + if (!$this->hasConfigBackendData()) { + $this->addTask('Drop column "civicrm_domain.config_backend"', 'dropColumn', 'civicrm_domain', 'config_backend'); + } } /** @@ -146,4 +159,12 @@ class CRM_Upgrade_Incremental_php_FiveTwentyThree extends CRM_Upgrade_Incrementa return TRUE; } + /** + * @return bool + */ + private function hasConfigBackendData() { + return CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_domain', 'config_backend') + && CRM_Core_DAO::singleValueQuery('SELECT count(*) c FROM `civicrm_domain` WHERE config_backend IS NOT NULL') > 0; + } + } -- 2.25.1