diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 1345c233094d..a87415b5eee6 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -148,6 +148,14 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { protected $_openedPanes = []; + public function __construct($state = NULL, $action = CRM_Core_Action::NONE, $method = 'post', $name = NULL) { + parent::__construct($state, $action, $method, $name); + // Because this is a static variable, reset it in case it got changed elsewhere. + // Should only come up during unit tests. + // Note the only subclass that seems to set this does it in preprocess (custom searches) + self::$_selectorName = 'CRM_Contact_Selector'; + } + /** * Explicitly declare the entity api name. */ diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index b9d8c7d19ac4..9ba5d4ce09e3 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -760,7 +760,7 @@ public static function addComponentFields(&$fields, $mappingType, $exportMode) { } } if (($mappingType == 'Search Builder') || ($exportMode == CRM_Export_Form_Select::GRANT_EXPORT)) { - if (CRM_Core_Permission::check('access CiviGrant')) { + if (method_exists('CRM_Grant_BAO_Grant', 'exportableFields') && CRM_Core_Permission::check('access CiviGrant')) { $fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields(); unset($fields['Grant']['grant_contact_id']); if ($mappingType == 'Search Builder') { diff --git a/tests/phpunit/CRM/Core/InvokeTest.php b/tests/phpunit/CRM/Core/InvokeTest.php index 0aae3e48a55b..74ec765d2123 100644 --- a/tests/phpunit/CRM/Core/InvokeTest.php +++ b/tests/phpunit/CRM/Core/InvokeTest.php @@ -51,4 +51,18 @@ public function testInvokeDashboardWithGettingStartedDashlet(): void { ob_end_clean(); } + public function testOpeningSearchBuilder(): void { + $_SERVER['REQUEST_URI'] = 'civicrm/contact/search/builder?reset=1'; + $_GET['q'] = 'civicrm/contact/search/builder'; + $_GET['reset'] = 1; + + $item = CRM_Core_Invoke::getItem([$_GET['q']]); + ob_start(); + CRM_Core_Invoke::runItem($item); + $contents = ob_get_clean(); + + unset($_GET['reset']); + $this->assertRegExp('/form.+id="Builder" class="CRM_Contact_Form_Search_Builder/', $contents); + } + }