From 6950579a6f5218a2f13e0dbce7bd1a309f8250ca Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Tue, 16 May 2023 08:18:53 -0600 Subject: [PATCH] Improve-slow-download-from-SearchKit-results --- .../Civi/Api4/Action/SearchDisplay/Download.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ext/search_kit/Civi/Api4/Action/SearchDisplay/Download.php b/ext/search_kit/Civi/Api4/Action/SearchDisplay/Download.php index 9429a17604..3278de5c2f 100644 --- a/ext/search_kit/Civi/Api4/Action/SearchDisplay/Download.php +++ b/ext/search_kit/Civi/Api4/Action/SearchDisplay/Download.php @@ -54,6 +54,13 @@ class Download extends AbstractRunAction { $apiParams =& $this->_apiParams; $settings = $this->display['settings']; + // checking permissions for menu, link or button columns is costly, so remove them early + foreach ($this->display['settings']['columns'] as $index => $col) { + if (empty($col['key'])) { + unset($this->display['settings']['columns'][$index]); + } + } + // Displays are only exportable if they have actions enabled if (empty($settings['actions'])) { \CRM_Utils_System::permissionDenied(); @@ -75,9 +82,7 @@ class Download extends AbstractRunAction { $columns = []; foreach ($this->display['settings']['columns'] as $index => $col) { $col += ['type' => NULL, 'label' => '', 'rewrite' => FALSE]; - if (!empty($col['key'])) { - $columns[$index] = $col; - } + $columns[$index] = $col; // Convert html to plain text if ($col['type'] === 'html') { foreach ($rows as $i => $row) { -- 2.25.1