From 5e12ab58bec3844100e7407137d75a43add9b22d Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Fri, 8 Sep 2017 10:01:00 -0400 Subject: [PATCH] WLFilters: Respect default values Followup to I3e48a9f2d9b70f0b9f6d7c6329db9c8e8001ee49 Reported in T174725#3590145 Comparing current value and active value with different representation ("1" !== true) leads to not applying filters that are ON by default. Bug: T174725 Change-Id: If083610c0294756589adfc32a59388cc7422ad5d --- includes/changes/ChangesListBooleanFilter.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/includes/changes/ChangesListBooleanFilter.php b/includes/changes/ChangesListBooleanFilter.php index 913bd3832f..dd62d7fd8e 100644 --- a/includes/changes/ChangesListBooleanFilter.php +++ b/includes/changes/ChangesListBooleanFilter.php @@ -235,10 +235,13 @@ class ChangesListBooleanFilter extends ChangesListFilter { * @inheritDoc */ public function isSelected( FormOptions $opts ) { - return !$opts[ $this->getName() ] && - array_filter( $this->getSiblings(), function ( $sibling ) use ( $opts ) { - return $opts[ $sibling->getName() ]; - } ); + return !$this->getValue( $opts ) && + array_filter( + $this->getSiblings(), + function ( ChangesListBooleanFilter $sibling ) use ( $opts ) { + return $sibling->getValue( $opts ); + } + ); } /** @@ -251,6 +254,14 @@ class ChangesListBooleanFilter extends ChangesListFilter { return false; } - return $opts[ $this->getName() ] === $this->activeValue; + return $this->getValue( $opts ) === $this->activeValue; + } + + /** + * @param FormOptions $opts + * @return bool The current value of this filter according to $opts but coerced to boolean + */ + public function getValue( FormOptions $opts ) { + return (bool)$opts[ $this->getName() ]; } } -- 2.20.1