From cc7fb280c374af1e34a293faf30d42f88d7498a9 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 12 Aug 2021 23:48:52 +0100 Subject: [PATCH 1/3] Remove broken makepastyearsubmissions job --- CRM/Civigiftaid/Upgrader.php | 52 +++++++++++------------------------- docs/releasenotes.md | 4 +++ info.xml | 8 +++--- 3 files changed, 24 insertions(+), 40 deletions(-) diff --git a/CRM/Civigiftaid/Upgrader.php b/CRM/Civigiftaid/Upgrader.php index cbe0f41..b6f28fe 100644 --- a/CRM/Civigiftaid/Upgrader.php +++ b/CRM/Civigiftaid/Upgrader.php @@ -39,13 +39,9 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { */ public function install() { $this->ensureDataStructures(); - // Nb. this is kept to preserve previous behaviour, it should not be needed. // Import existing batches. self::importBatches(); - - $this->ensurePastYearSubmissionJob(); - // In case this extension had been installed and uninstalled before: $this->removeLegacyRegisteredReport(); } @@ -362,29 +358,6 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { 'label' => 'Post code', 'field_type' => 'Contact', ]); - - } - /** - * Set up Past Year Submissions Job - */ - public function ensurePastYearSubmissionJob() { - $existing = civicrm_api3('Job', 'get', [ - 'api_entity' => "gift_aid", - 'api_action' => "makepastyearsubmissions", - ]); - - if (empty($existing['count'])) { - $jobParams = [ - 'domain_id' => CRM_Core_Config::domainID(), - 'run_frequency' => 'Daily', - 'name' => 'Make Past Year Submissions', - 'description' => 'Make Past Year Submissions', - 'api_entity' => 'gift_aid', - 'api_action' => 'makepastyearsubmissions', - 'is_active' => 0, - ]; - civicrm_api3('Job', 'create', $jobParams); - } } /** @@ -531,15 +504,6 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { return TRUE; } - /** - * Set up Past Year Submissions Job - */ - public function upgrade_3101() { - $this->log('Applying update 3101 - Add past year submissions job'); - $this->ensurePastYearSubmissionJob(); - return TRUE; - } - public function upgrade_3102() { $this->log('Applying update 3102'); @@ -666,6 +630,22 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { return TRUE; } + public function upgrade_3116() { + $this->log('Remove GiftAid.Makepastyearsubmissions scheduled job'); + $jobsToDelete = civicrm_api3('Job', 'get', [ + 'api_entity' => "gift_aid", + 'api_action' => "makepastyearsubmissions", + ]); + if ($jobsToDelete['count'] > 0) { + foreach ($jobsToDelete['values'] as $jobID => $jobDetail) { + civicrm_api3('Job', 'delete', [ + 'id' => $jobID, + ]); + } + } + return TRUE; + } + /** * @return array */ diff --git a/docs/releasenotes.md b/docs/releasenotes.md index 280754d..9e2f1a1 100644 --- a/docs/releasenotes.md +++ b/docs/releasenotes.md @@ -9,6 +9,10 @@ Releases use the following numbering system: * **[BC]**: Items marked with [BC] indicate a breaking change that will require updates to your code if you are using that code in your extension. +## Release 3.4.9 (not yet released) + +* Remove broken `GiftAid.Makepastyearsubmissions` scheduled job (the API call was actually removed a year ago). + ## Release 3.4.8 * Fix exporting when batchID filter is specified via URL. diff --git a/info.xml b/info.xml index 5ec906c..c59acf3 100644 --- a/info.xml +++ b/info.xml @@ -18,11 +18,11 @@ MJW Consulting, Rich Lott (Artful Robot) Erawat Chamanont, Jamie Novick, Guanhuan Chen, Robin Mitra mjw@mjwconsult.co.uk, https://artfulrobot.uk, jamie@compucorp.co.uk, guanhuan@compucorp.co.uk - 2021-03-25 - 3.4.8 - stable + 2021-08-12 + 3.4.9-dev + beta - 5.28 + 5.35 CRM/Civigiftaid -- GitLab From 9a22e643c8f0bc08805f832896dd6d76aebb7e33 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 12 Aug 2021 23:50:31 +0100 Subject: [PATCH 2/3] Upgrader fixes --- CRM/Civigiftaid/Upgrader.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CRM/Civigiftaid/Upgrader.php b/CRM/Civigiftaid/Upgrader.php index b6f28fe..6c941d2 100644 --- a/CRM/Civigiftaid/Upgrader.php +++ b/CRM/Civigiftaid/Upgrader.php @@ -971,7 +971,7 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { return $optionGroups; } - private function getOptionValues($optionGroups) { + private function getOptionValues() { $optionValues = [ // eligibility_declaration_options: these apply to contacts and record details // about their declarations. @@ -1063,12 +1063,11 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { private function setOptionGroups() { foreach ($this->getOptionGroups() as $groupName => $groupParams) { - // Create the option groups. $optionGroups[$groupName] = civicrm_api3('OptionGroup', 'get', [ 'name' => $groupName, ]); - if ($optionGroups[$groupName]['id'] ?? NULL) { + if (!empty($optionGroups[$groupName]['id'])) { $groupParams['id'] = $optionGroups[$groupName]['id']; } // Add new option groups and options @@ -1078,7 +1077,7 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base { } // Create the values within the groups. - $optionValues = $this->getOptionValues($optionGroups); + $optionValues = $this->getOptionValues(); foreach($optionValues as $params) { $optionValue = civicrm_api3('OptionValue', 'get', [ 'option_group_id' => $params['option_group_id'], -- GitLab From 81792c62a11c7ab49a103a02c6d1483822a09f7b Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 12 Aug 2021 23:50:55 +0100 Subject: [PATCH 3/3] Regenerate civix --- civigiftaid.civix.php | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/civigiftaid.civix.php b/civigiftaid.civix.php index 1d4df35..afec95e 100644 --- a/civigiftaid.civix.php +++ b/civigiftaid.civix.php @@ -221,7 +221,8 @@ function _civigiftaid_civix_upgrader() { * Search directory tree for files which match a glob pattern. * * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored. - * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles() + * Note: Delegate to CRM_Utils_File::findFiles(), this function kept only + * for backward compatibility of extension code that uses it. * * @param string $dir base dir * @param string $pattern , glob pattern, eg "*.txt" @@ -229,32 +230,7 @@ function _civigiftaid_civix_upgrader() { * @return array */ function _civigiftaid_civix_find_files($dir, $pattern) { - if (is_callable(['CRM_Utils_File', 'findFiles'])) { - return CRM_Utils_File::findFiles($dir, $pattern); - } - - $todos = [$dir]; - $result = []; - while (!empty($todos)) { - $subdir = array_shift($todos); - foreach (_civigiftaid_civix_glob("$subdir/$pattern") as $match) { - if (!is_dir($match)) { - $result[] = $match; - } - } - if ($dh = opendir($subdir)) { - while (FALSE !== ($entry = readdir($dh))) { - $path = $subdir . DIRECTORY_SEPARATOR . $entry; - if ($entry[0] == '.') { - } - elseif (is_dir($path)) { - $todos[] = $path; - } - } - closedir($dh); - } - } - return $result; + return CRM_Utils_File::findFiles($dir, $pattern); } /** -- GitLab