Fix header e-notices
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 26 Sep 2021 22:21:42 +0000 (11:21 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 29 Sep 2021 07:28:50 +0000 (20:28 +1300)
This should solve enotices across a bunch of screens

CRM/Core/Selector/Controller.php

index 533d4042a2287b6b23deabe0c35662a4cf8c68f3..66dd528f0bb9cd76784f544fe32c78b048170b99 100644 (file)
@@ -461,7 +461,17 @@ class CRM_Core_Selector_Controller {
     }
 
     self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort);
-    self::$_template->assign("{$this->_prefix}columnHeaders", $this->_store->get("{$this->_prefix}columnHeaders"));
+    $columnHeaders = (array) $this->_store->get("{$this->_prefix}columnHeaders");
+    foreach ($columnHeaders as $index => $columnHeader) {
+      // Fill out the keys to avoid e-notices.
+      if (!isset($columnHeader['sort'])) {
+        $columnHeaders[$index]['sort'] = NULL;
+      }
+      if (!isset($columnHeader['name'])) {
+        $columnHeaders[$index]['name'] = NULL;
+      }
+    }
+    self::$_template->assign("{$this->_prefix}columnHeaders", $columnHeaders);
     self::$_template->assign("{$this->_prefix}rows", $rows);
     self::$_template->assign("{$this->_prefix}rowsEmpty", $this->_store->get("{$this->_prefix}rowsEmpty"));
     self::$_template->assign("{$this->_prefix}qill", $this->_store->get("{$this->_prefix}qill"));