Show correct default limit in Special:BlockList
authorFlorianschmidtwelzow <florian.schmidt.welzow@t-online.de>
Wed, 27 May 2015 06:21:26 +0000 (08:21 +0200)
committerFlorian <florian.schmidt.stargatewissen@gmail.com>
Sat, 25 Jul 2015 21:50:55 +0000 (23:50 +0200)
Instead of hardcoded default of 50, use the default, which is used
in BlockListPager, which can be a user setting.

Bug: T71132
Change-Id: I5a7f0eb71782cc2282098368a2caf9c893b688fa

includes/specials/SpecialBlockList.php

index ebc02a5..9defaba 100644 (file)
@@ -65,6 +65,9 @@ class SpecialBlockList extends SpecialPage {
                        return;
                }
 
+               # setup BlockListPager here to get the actual default Limit
+               $pager = $this->getBlockListPager();
+
                # Just show the block list
                $fields = array(
                        'Target' => array(
@@ -96,7 +99,7 @@ class SpecialBlockList extends SpecialPage {
                                        $lang->formatNum( 500 ) => 500,
                                ),
                                'name' => 'limit',
-                               'default' => 50,
+                               'default' => $pager->getLimit(),
                        ),
                );
                $context = new DerivativeContext( $this->getContext() );
@@ -109,10 +112,14 @@ class SpecialBlockList extends SpecialPage {
                $form->prepareForm();
 
                $form->displayForm( '' );
-               $this->showList();
+               $this->showList( $pager );
        }
 
-       function showList() {
+       /**
+        * Setup a new BlockListPager instance.
+        * @return BlockListPager
+        */
+       protected function getBlockListPager() {
                $conds = array();
                # Is the user allowed to see hidden blocks?
                if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
@@ -163,12 +170,20 @@ class SpecialBlockList extends SpecialPage {
                        $conds[] = "ipb_range_end = ipb_range_start";
                }
 
+               return new BlockListPager( $this, $conds );
+       }
+
+       /**
+        * Show the list of blocked accounts matching the actual filter.
+        * @param BlockListPager $pager The BlockListPager instance for this page
+        */
+       protected function showList( BlockListPager $pager ) {
+               $out = $this->getOutput();
+
                # Check for other blocks, i.e. global/tor blocks
                $otherBlockLink = array();
                Hooks::run( 'OtherBlockLogLink', array( &$otherBlockLink, $this->target ) );
 
-               $out = $this->getOutput();
-
                # Show additional header for the local block only when other blocks exists.
                # Not necessary in a standard installation without such extensions enabled
                if ( count( $otherBlockLink ) ) {
@@ -177,7 +192,6 @@ class SpecialBlockList extends SpecialPage {
                        );
                }
 
-               $pager = new BlockListPager( $this, $conds );
                if ( $pager->getNumRows() ) {
                        $out->addParserOutputContent( $pager->getFullOutput() );
                } elseif ( $this->target ) {