From ea94945b84ed504148fa227b5d7a58371689aa5f Mon Sep 17 00:00:00 2001 From: Eli Van Zoeren Date: Thu, 10 Oct 2024 11:06:34 -0400 Subject: [PATCH 1/2] Prevent PHP error in ConditionHelper when Commerce is installed --- src/core/helpers/ConditionHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/helpers/ConditionHelper.php b/src/core/helpers/ConditionHelper.php index 2388acc..f842faf 100644 --- a/src/core/helpers/ConditionHelper.php +++ b/src/core/helpers/ConditionHelper.php @@ -10,7 +10,7 @@ class ConditionHelper { public static function registerConditionRuleTypes(RegisterConditionRulesEvent $event): void { - $elementType = $event->sender?->elementType; + $elementType = $event->sender?->elementType ?? null; if ($elementType === null) { return; From 5380cdee0ac4610e0fc006f12ba016bbdcd08231 Mon Sep 17 00:00:00 2001 From: Rodrigo Passos Date: Tue, 19 Nov 2024 14:52:05 -0500 Subject: [PATCH 2/2] Refactor header row handling in CustomTwigTemplateQueryDataSource --- .../CustomTwigTemplateQueryDataSource.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/datastudio/components/datasources/CustomTwigTemplateQueryDataSource.php b/src/datastudio/components/datasources/CustomTwigTemplateQueryDataSource.php index fef9e47..ce598de 100644 --- a/src/datastudio/components/datasources/CustomTwigTemplateQueryDataSource.php +++ b/src/datastudio/components/datasources/CustomTwigTemplateQueryDataSource.php @@ -176,23 +176,21 @@ public function processHeaderRow(&$rows): void // If we don't have default labels, we will use the first row as for our column headers // We do so by making the first row the keys of the second row if (empty($labels) && is_countable($rows) && count($rows) === 0) { - return; - } - - $headerRow = []; + $headerRow = []; - /** @var array $firstRowColumns */ - $firstRowColumns = array_shift($rows); + /** @var array $firstRowColumns */ + $firstRowColumns = array_shift($rows); - if (is_countable($firstRowColumns) && count($firstRowColumns) > 0) { - $secondRow = array_shift($rows); + if (is_countable($firstRowColumns) && count($firstRowColumns) > 0) { + $secondRow = array_shift($rows); - foreach ($firstRowColumns as $key => $column) { - $headerRow[$column] = $secondRow[$key]; + foreach ($firstRowColumns as $key => $column) { + $headerRow[$column] = $secondRow[$key]; + } } - } - array_unshift($rows, $headerRow); + array_unshift($rows, $headerRow); + } } /**