LogPager: Add backwards-compatibility for hide_[type]_log URL params
authorPrateek Saxena <prtksxna@gmail.com>
Thu, 19 Jul 2018 05:02:24 +0000 (10:32 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Fri, 20 Jul 2018 01:48:46 +0000 (07:18 +0530)
Also, the $default value in LogEventsList#getFiltersDesc was not
being generated properly and would have always been an empty array.

Bug: T199856
Change-Id: Id286c76259406521f12cda67a4a715032e022637

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

index 95439b9..7462dbf 100644 (file)
@@ -198,7 +198,7 @@ class LogEventsList extends ContextSource {
                foreach ( $filter as $type => $val ) {
                        $options[ $this->msg( "logeventslist-{$type}-log" )->text() ] = $type;
 
-                       if ( $val === 0 ) {
+                       if ( $val === false ) {
                                $default[] = $type;
                        }
                }
index 2efb462..e7096c4 100644 (file)
@@ -107,12 +107,17 @@ class LogPager extends ReverseChronologicalPager {
                        return $filters;
                }
 
-               $request_filters = $this->getRequest()->getArray( "wpfilters" );
-               $request_filters = $request_filters === null ? [] : $request_filters;
+               $wpfilters = $this->getRequest()->getArray( "wpfilters" );
+               $request_filters = $wpfilters === null ? [] : $wpfilters;
 
                foreach ( $wgFilterLogTypes as $type => $default ) {
                        $hide = !in_array( $type, $request_filters );
 
+                       // Back-compat: Check old URL params if the new param wasn't passed
+                       if ( $wpfilters === null ) {
+                               $hide = $this->getRequest()->getBool( "hide_{$type}_log", $default );
+                       }
+
                        $filters[$type] = $hide;
                        if ( $hide ) {
                                $this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );