CRM-20451 Do no assume all BAOs have exportableFields method in Core_report
authoreileen <emcnaughton@wikimedia.org>
Thu, 20 Apr 2017 02:42:44 +0000 (14:42 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 20 Apr 2017 02:42:48 +0000 (14:42 +1200)
CRM/Report/Form.php

index b33215bfdeb90f63cc9e58ddf17e260485aa138d..1ecc52d633ddb7a1344aa59441182d51dca32e9c 100644 (file)
@@ -701,18 +701,17 @@ class CRM_Report_Form extends CRM_Core_Form {
 
       $this->_aliases[$tableName] = $this->_columns[$tableName]['alias'];
 
-      $daoOrBaoName = NULL;
+      $expFields = array();
       // higher preference to bao object
-      if (array_key_exists('bao', $table)) {
-        $daoOrBaoName = $table['bao'];
-        $expFields = $daoOrBaoName::exportableFields();
-      }
-      elseif (array_key_exists('dao', $table)) {
-        $daoOrBaoName = $table['dao'];
-        $expFields = $daoOrBaoName::export();
-      }
-      else {
-        $expFields = array();
+      $daoOrBaoName = CRM_Utils_Array::value('bao', $table, CRM_Utils_Array::value('dao', $table));
+
+      if ($daoOrBaoName) {
+        if (method_exists($daoOrBaoName, 'exportableFields')) {
+          $expFields = $daoOrBaoName::exportableFields();
+        }
+        else {
+          $expFields = $daoOrBaoName::export();
+        }
       }
 
       $doNotCopy = array('required');