jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/381049 )

Change subject: Ensure numeric keys without gaps in 
ChoiceDataProvider::getChoices()
......................................................................


Ensure numeric keys without gaps in ChoiceDataProvider::getChoices()

Bug: T175358
Change-Id: I566cf377e2675cb419b018c6a0cd1c8a6c45cc60
(cherry picked from commit 1c462f6cba493ec33211265f576227a617906fe7)
---
M includes/ChoiceDataProvider.php
1 file changed, 8 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  AndyRussG: Looks good to me, approved



diff --git a/includes/ChoiceDataProvider.php b/includes/ChoiceDataProvider.php
index ca37a6f..9edc85d 100644
--- a/includes/ChoiceDataProvider.php
+++ b/includes/ChoiceDataProvider.php
@@ -66,11 +66,15 @@
                );
 
                // Filter out campaigns that have ended since we last queried 
the
-               // database or which have not started yet.
+               // database or which have not started yet. array_values 
re-orders numeric
+               // keys, in case elements were removed.
                $now = time();
-               return array_filter( $choices, function ( $choice ) use ( $now 
) {
-                       return $choice['end'] >= $now && $choice['start'] <= 
$now;
-               } );
+               return array_values( array_filter(
+                       $choices,
+                       function ( $choice ) use ( $now ) {
+                               return $choice['end'] >= $now && 
$choice['start'] <= $now;
+                       }
+               ) );
        }
 
        private static function fetchChoices( $project, $language,

-- 
To view, visit https://gerrit.wikimedia.org/r/381049
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I566cf377e2675cb419b018c6a0cd1c8a6c45cc60
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: wmf_deploy
Gerrit-Owner: AndyRussG <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to