From 9c41fa61367e8375f1240b60998fbe6dd8a048e7 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Wed, 20 Sep 2017 17:46:50 +0530 Subject: [PATCH] add upgrade code --- CRM/Upgrade/Incremental/php/FourSeven.php | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index a80352a4cb..252aaeb2a6 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -456,6 +456,16 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base $this->addTask('Remove broken Contribution_logging reports', 'removeContributionLoggingReports'); } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_4_7_27($rev) { + $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('CRM-20572: Fix date fields in save search criteria of Contrib Sybunt custom search ', 'fixDateFieldsInSmartGroups'); + } + /* * Important! All upgrade functions MUST add a 'runSql' task. * Uncomment and use the following template for a new upgrade version @@ -1287,4 +1297,22 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return $config->imageUploadDir && $config->imageUploadURL && $check->isDirAccessible($config->imageUploadDir, $config->imageUploadURL); } + /** + * CRM-20572 - Format date fields in Contrib Sybunt custom search's saved criteria. + * + * @param \CRM_Queue_TaskContext $ctx + * + * @return bool + */ + public static function fixDateFieldsInSmartGroups(CRM_Queue_TaskContext $ctx) { + $dao = CRM_Core_DAO::executeQuery("SELECT id, form_values FROM civicrm_saved_search WHERE form_values LIKE '%CRM_Contact_Form_Search_Custom_ContribSYBNT%'"); + while ($dao->fetch()) { + $formValues = unserialize($dao->form_values); + CRM_Contact_Form_Search_Custom_ContribSYBNT::formatSavedSearchFields($formValues); + CRM_Core_DAO::executeQuery("UPDATE civicrm_saved_search SET form_values = %1 WHERE id = {$dao->id}", array(1 => array(serialize($formValues), 'String'))); + } + + return TRUE; + } + } -- 2.25.1