Merge "WLFilters: Respect default values"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 8 Sep 2017 17:31:27 +0000 (17:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 8 Sep 2017 17:31:27 +0000 (17:31 +0000)
includes/changes/ChangesListBooleanFilter.php

index 913bd38..dd62d7f 100644 (file)
@@ -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() ];
        }
 }