Sbisson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376766 )

Change subject: WLFilters: Respect default values
......................................................................

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
(cherry picked from commit 5e12ab58bec3844100e7407137d75a43add9b22d)
---
M includes/changes/ChangesListBooleanFilter.php
1 file changed, 16 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/66/376766/1

diff --git a/includes/changes/ChangesListBooleanFilter.php 
b/includes/changes/ChangesListBooleanFilter.php
index 913bd38..dd62d7f 100644
--- a/includes/changes/ChangesListBooleanFilter.php
+++ b/includes/changes/ChangesListBooleanFilter.php
@@ -235,10 +235,13 @@
         * @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 @@
                        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() ];
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If083610c0294756589adfc32a59388cc7422ad5d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.30.0-wmf.17
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to