From d0513fddd378cbe7ae2948fc838ee69cf8cf5090 Mon Sep 17 00:00:00 2001 From: Greg Dean Date: Mon, 14 Dec 2020 15:32:34 -0500 Subject: [PATCH 1/2] adding array_values to getRawDataRealms to ensure that the returned array is indexed to 0 and is sequential --- classes/DataWarehouse/Data/RawStatisticsConfiguration.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/DataWarehouse/Data/RawStatisticsConfiguration.php b/classes/DataWarehouse/Data/RawStatisticsConfiguration.php index 511a2c6219..6229682f5a 100644 --- a/classes/DataWarehouse/Data/RawStatisticsConfiguration.php +++ b/classes/DataWarehouse/Data/RawStatisticsConfiguration.php @@ -97,7 +97,7 @@ public function getRawDataRealms() return []; } - return array_filter( + $rawDataRealms = array_filter( $this->config['realms'], function ($realm) { // If the "raw_data" key doesn't exist the realm is assumed to @@ -106,6 +106,10 @@ function ($realm) { && $realm['raw_data'] === false); } ); + + // array_values is used to reset the keys of the array to start a 0 and + // be sequential + return array_values($rawDataRealms); } /** From 24f9d29bdd135d6fb30d2b67e4a7a7281a4f3f35 Mon Sep 17 00:00:00 2001 From: Greg Dean Date: Tue, 15 Dec 2020 07:30:14 -0500 Subject: [PATCH 2/2] adding comments to explain change --- classes/DataWarehouse/Data/RawStatisticsConfiguration.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/DataWarehouse/Data/RawStatisticsConfiguration.php b/classes/DataWarehouse/Data/RawStatisticsConfiguration.php index 6229682f5a..3d89660511 100644 --- a/classes/DataWarehouse/Data/RawStatisticsConfiguration.php +++ b/classes/DataWarehouse/Data/RawStatisticsConfiguration.php @@ -97,6 +97,9 @@ public function getRawDataRealms() return []; } + // The elements returned from array filter preserve their keys. This + // may cause gaps since the keys are numeric. array_keys is used below + // to reindex the keys $rawDataRealms = array_filter( $this->config['realms'], function ($realm) { @@ -107,8 +110,6 @@ function ($realm) { } ); - // array_values is used to reset the keys of the array to start a 0 and - // be sequential return array_values($rawDataRealms); }