AndyRussG has uploaded a new change for review. (
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
---
M includes/ChoiceDataProvider.php
1 file changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/49/381049/1
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: newchange
Gerrit-Change-Id: I566cf377e2675cb419b018c6a0cd1c8a6c45cc60
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: wmf_deploy
Gerrit-Owner: AndyRussG <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits