CRM-17004 - Fix upgrade query for removing payment processors
authorColeman Watts <coleman@civicrm.org>
Thu, 8 Oct 2015 19:39:49 +0000 (15:39 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 9 Oct 2015 21:56:59 +0000 (17:56 -0400)
CRM/Upgrade/Incremental/Base.php
CRM/Upgrade/Incremental/php/FourSeven.php

index 7b8abadaa5741c3e35cfb217512ed3897dcda0a2..d4eb3113e76b6411cf732489d3e3e8a20a689412 100644 (file)
@@ -106,10 +106,12 @@ class CRM_Upgrade_Incremental_Base {
   /**
    * Remove a payment processor if not in use
    *
-   * @param $name
+   * @param CRM_Queue_TaskContext $ctx
+   * @param string $name
+   * @return bool
    * @throws \CiviCRM_API3_Exception
    */
-  public static function removePaymentProcessorType($name) {
+  public static function removePaymentProcessorType(CRM_Queue_TaskContext $ctx, $name) {
     $processors = civicrm_api3('PaymentProcessor', 'getcount', array('payment_processor_type_id' => $name));
     if (empty($processors['result'])) {
       $result = civicrm_api3('PaymentProcessorType', 'get', array(
@@ -120,6 +122,7 @@ class CRM_Upgrade_Incremental_Base {
         civicrm_api3('PaymentProcessorType', 'delete', array('id' => $result['id']));
       }
     }
+    return TRUE;
   }
 
 }
index 8382fdfe02f5e166c4eb359bff05e72ba7dd1e89..9565373de531ba0339ec759b266e8695f6437b72 100644 (file)
@@ -52,8 +52,12 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
     }
     if ($rev == '4.7.alpha4') {
       // CRM-17004 Warn of Moneris removal
-      $monerisProcessors = civicrm_api3('PaymentProcessor', 'getcount', array('payment_processor_type_id' => "Moneris"));
-      if (!empty($monerisProcessors['result']) && !function_exists('moneris_civicrm_managed')) {
+      $count = 1;
+      // Query only works in 4.3+
+      if (version_compare($currentVer, "4.3.0") > 0) {
+        $count = CRM_Core_DAO::singleValueQuery("SELECT COUNT(id) FROM civicrm_payment_processor WHERE payment_processor_type_id IN (SELECT id FROM civicrm_payment_processor_type WHERE name = 'Moneris')");
+      }
+      if ($count && !function_exists('moneris_civicrm_managed')) {
         $preUpgradeMessage .= '<p>' . ts('The %1 payment processor is no longer bundled with CiviCRM. After upgrading you will need to install the extension to continue using it.', array(1 => 'Moneris')) . '</p>';
       }
     }