From 095060e1b7424f709d7947633c3bf764023873e7 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 13 Mar 2022 01:26:10 -0500 Subject: [PATCH] Fix backward-compatability for new method in CRM_Contact_BAO_Query_Hook The method getDefaultReturnProperties was just added to CRM_Contact_BAO_Query_Hook, but some extensions do not yet implement it, and also do not extend that class so cannot inherit the default method. This adds a guard around calling the new method to avoid crashes. --- CRM/Contact/BAO/Query/Hook.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/BAO/Query/Hook.php b/CRM/Contact/BAO/Query/Hook.php index ae6ee974a373..01e68fb666e1 100644 --- a/CRM/Contact/BAO/Query/Hook.php +++ b/CRM/Contact/BAO/Query/Hook.php @@ -150,14 +150,22 @@ public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type } /** + * This gives the opportunity for a single hook to return default fields. + * + * It only runs if no core components have defaults for this $mode. + * The expectation is that only one hook will handle this mode, so just + * the first one to return a value is used. + * * @param $mode * @return array|null */ public function getDefaultReturnProperties($mode) { - foreach (self::getSearchQueryObjects() as $obj) { - $properties = $obj::defaultReturnProperties($mode); - if ($properties) { - return $properties; + foreach ($this->getSearchQueryObjects() as $obj) { + if (method_exists($obj, 'defaultReturnProperties')) { + $properties = $obj::defaultReturnProperties($mode); + if ($properties) { + return $properties; + } } } return NULL;