From 6ec388a8153c42225bc111ce78dcbfcaddb43154 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 18 Sep 2020 17:14:00 +1200 Subject: [PATCH] [REF] Remove checks as to whether entityShortName is in the component array If entityShortName is not in components then formTaskClassName will never be set & later down the attempt to use that variable in formTaskClassName::preProcessCommon MUST fail - ergo it is always in components. To make it really explicit I added the exception & hard-coded list as I think it would be easy to revisit this later without that --- CRM/Export/Form/Select.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/CRM/Export/Form/Select.php b/CRM/Export/Form/Select.php index 8710d85236..cb95ff243b 100644 --- a/CRM/Export/Form/Select.php +++ b/CRM/Export/Form/Select.php @@ -76,28 +76,28 @@ class CRM_Export_Form_Select extends CRM_Core_Form_Task { $this->_componentIds = []; $this->_componentClause = NULL; - // we need to determine component export - $components = CRM_Export_BAO_Export::getComponents(); - // FIXME: This should use a modified version of CRM_Contact_Form_Search::getModeValue but it doesn't have all the contexts // FIXME: Or better still, use CRM_Core_DAO_AllCoreTables::getBriefName($daoName) to get the $entityShortName $entityShortname = $this->getEntityShortName(); - if (in_array($entityShortname, $components)) { - $this->_exportMode = constant('CRM_Export_Form_Select::' . strtoupper($entityShortname) . '_EXPORT'); - $formTaskClassName = "CRM_{$entityShortname}_Form_Task"; - $taskClassName = "CRM_{$entityShortname}_Task"; - if (isset($formTaskClassName::$entityShortname)) { - $this::$entityShortname = $formTaskClassName::$entityShortname; - if (isset($formTaskClassName::$tableName)) { - $this::$tableName = $formTaskClassName::$tableName; - } - } - else { - $this::$entityShortname = $entityShortname; - $this::$tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($this->getDAOName())); + if (!in_array($entityShortname, ['Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity'], TRUE)) { + // This is never reached - the exception here is just to clarify that entityShortName MUST be one of the above + // to save future refactorers & reviewers from asking that question. + throw new CRM_Core_Exception('Unreachable code'); + } + $this->_exportMode = constant('CRM_Export_Form_Select::' . strtoupper($entityShortname) . '_EXPORT'); + $formTaskClassName = "CRM_{$entityShortname}_Form_Task"; + $taskClassName = "CRM_{$entityShortname}_Task"; + if (isset($formTaskClassName::$entityShortname)) { + $this::$entityShortname = $formTaskClassName::$entityShortname; + if (isset($formTaskClassName::$tableName)) { + $this::$tableName = $formTaskClassName::$tableName; } } + else { + $this::$entityShortname = $entityShortname; + $this::$tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($this->getDAOName())); + } // get the submitted values based on search if ($this->_action == CRM_Core_Action::ADVANCED) { @@ -110,7 +110,7 @@ class CRM_Export_Form_Select extends CRM_Core_Form_Task { $values = $this->controller->exportValues('Custom'); } else { - if (in_array($entityShortname, $components) && $entityShortname !== 'Contact') { + if ($entityShortname !== 'Contact') { $values = $this->controller->exportValues('Search'); } else { -- 2.25.1