Prevent "Undefined offset notice"
authorMatěj Suchánek <matejsuchanek97@gmail.com>
Fri, 8 Jun 2018 13:34:41 +0000 (13:34 +0000)
committerMatěj Suchánek <matejsuchanek97@gmail.com>
Fri, 29 Jun 2018 07:42:36 +0000 (07:42 +0000)
The number provided by the query can be arbitrary, so let's narrow the
input validation to booleans.

Bug: T194616
Change-Id: If03e6e2d5bbcf4f2d85047cc23ee5388b39fe114

includes/logging/LogEventsList.php
includes/logging/LogPager.php

index 911a8cc..7b8ffef 100644 (file)
@@ -177,7 +177,7 @@ class LogEventsList extends ContextSource {
                        $query = $this->getDefaultQuery();
                        $queryKey = "hide_{$type}_log";
 
-                       $hideVal = 1 - intval( $val );
+                       $hideVal = $val ? 0 : 1;
                        $query[$queryKey] = $hideVal;
 
                        $link = $linkRenderer->makeKnownLink(
index 84653b1..6b177ae 100644 (file)
@@ -105,7 +105,7 @@ class LogPager extends ReverseChronologicalPager {
                        return $filters;
                }
                foreach ( $wgFilterLogTypes as $type => $default ) {
-                       $hide = $this->getRequest()->getInt( "hide_{$type}_log", $default );
+                       $hide = $this->getRequest()->getBool( "hide_{$type}_log", $default );
 
                        $filters[$type] = $hide;
                        if ( $hide ) {