From 87a33a95e8baaba737e0a139692bb1f0570a0e62 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 8 Oct 2015 15:39:49 -0400 Subject: [PATCH] CRM-17004 - Fix upgrade query for removing payment processors --- CRM/Upgrade/Incremental/Base.php | 7 +++++-- CRM/Upgrade/Incremental/php/FourSeven.php | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index 7b8abadaa5..d4eb3113e7 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -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; } } diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 8382fdfe02..9565373de5 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -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 .= '

' . 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')) . '

'; } } -- 2.25.1