CRM-12084 fix
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Wed, 13 Mar 2013 09:55:50 +0000 (15:25 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Wed, 13 Mar 2013 09:55:50 +0000 (15:25 +0530)
CRM/Upgrade/Incremental/php/FourThree.php
sql/civicrm_generated.mysql
xml/version.xml

index 380438644913ebce56bd759a889255c90d2c8317..61beb1133ba7f37b31e81b364249c7962d04772f 100644 (file)
@@ -39,6 +39,31 @@ class CRM_Upgrade_Incremental_php_FourThree {
     return TRUE;
   }
 
+  /**
+   * Compute any messages which should be displayed beforeupgrade
+   *
+   * Note: This function is called iteratively for each upcoming
+   * revision to the database.
+   *
+   * @param $postUpgradeMessage string, alterable
+   * @param $rev string, a version number, e.g. '4.3.alpha1', '4.3.beta3', '4.3.0'
+   * @return void
+   */
+  function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
+    if (version_compare($rev, '4.3.beta3') >= 0) {
+      //CRM-12084
+      //sql for checking orphaned contribution records
+      $sql = "SELECT COUNT(ct.id) FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL";
+      $count = CRM_Core_DAO::singleValueQuery($sql, array(), TRUE, FALSE);
+
+      if ($count > 0) {
+        $error = ts("There is a data integrity issue with this CiviCRM database. It contains %1 contribution records which are linked to contact records that have been deleted. You will need to correct this manually before you can run the upgrade. Use the following MySQL query to identify the problem records: %2 These records will need to be deleted or linked to an existing contact record.", array(1 => $count, 2 => '<em>SELECT ct.* FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL;</em>'));
+        CRM_Core_Error::fatal($error);
+        return FALSE;
+      }
+    }
+  }
+
   /**
    * Compute any messages which should be displayed after upgrade
    *
@@ -66,7 +91,7 @@ class CRM_Upgrade_Incremental_php_FourThree {
         $postUpgradeMessage .= '<br />' . ts("A new organization contact has been added as the default domain contact using the information from your Organization Address and Contact Info settings: '{$orgName}'.");
       }
       elseif ($context == 'merged') {
-        $postUpgradeMessage .= '<br />' . ts("The existing organization contact record for '{$orgName}' has marked as the default domain contact, and has been updated with information from your Organization Address and Contact Info settings.");
+        $postUpgradeMessage .= '<br />' . ts("The existing organization contact record for '{$orgName}' has been marked as the default domain contact, and has been updated with information from your Organization Address and Contact Info settings.");
       }
 
       $providerExists = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_sms_provider LIMIT 1");
@@ -98,7 +123,6 @@ WHERE    entity_value = '' OR entity_value IS NULL
     if ($rev == '4.3.beta2') {
       $postUpgradeMessage .= '<br />' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: <ul><li>Events - Registration Confirmation and Receipt (on-line)</li><li>Events - Registration Confirmation and Receipt (off-line)</li><li>Pledges - Acknowledgement</li><li>Pledges - Payment Reminder</li><li>Contributions - Receipt (off-line)</li><li>Contributions - Receipt (on-line)</li><li>Memberships - Signup and Renewal Receipts (off-line)</li><li>Memberships - Receipt (on-line)</li><li>Personal Campaign Pages - Admin Notification</li></ul> If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).');
     }
-
   }
 
   function upgrade_4_3_alpha1($rev) {
index 9d37c8f4d65254a93e34a2f6b482751b15c3e34c..c01374e68276b769583480d4fe902b538658a398 100644 (file)
@@ -392,7 +392,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_domain` WRITE;
 /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.3.beta2',1,NULL,NULL);
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.3.beta3',1,NULL,NULL);
 /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
 UNLOCK TABLES;
 
index d8881c794814504fc18cd7e71475a7d7fc63392b..4ad474563ee23db3b72b260a0f1f2e0de86421a8 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
 <version>
-    <version_no>4.3.beta2</version_no>
+    <version_no>4.3.beta3</version_no>
 </version>