Avoid master queries on SpecialBlockList
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 6 Apr 2015 22:19:56 +0000 (15:19 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 6 Apr 2015 22:19:56 +0000 (15:19 -0700)
* Filter out expired rows and rely on the insert() pruning
  to keep the table size reasonable.

Bug: T92357
Change-Id: Icdbd606979d3d9ce9b2d923f574447e3e7dd72f7

includes/specials/SpecialBlockList.php

index 4583430..0ec144a 100644 (file)
@@ -113,11 +113,6 @@ class SpecialBlockList extends SpecialPage {
        }
 
        function showList() {
-               # Purge expired entries on one in every 10 queries
-               if ( !mt_rand( 0, 10 ) ) {
-                       Block::purgeExpired();
-               }
-
                $conds = array();
                # Is the user allowed to see hidden blocks?
                if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
@@ -398,6 +393,10 @@ class BlockListPager extends TablePager {
                        'join_conds' => array( 'user' => array( 'LEFT JOIN', 'user_id = ipb_by' ) )
                );
 
+               # Filter out any expired blocks
+               $db = $this->getDatabase();
+               $info['conds'][] = 'ipb_expiry > ' . $db->addQuotes( $db->timestamp() );
+
                # Is the user allowed to see hidden blocks?
                if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
                        $info['conds']['ipb_deleted'] = 0;