Remove Block::purgeExpired() call from block query API
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 28 Aug 2016 18:37:39 +0000 (11:37 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 29 Aug 2016 16:17:07 +0000 (16:17 +0000)
This avoids master queries on HTTP GET. Filter out rows on the
fly and allow for pruning to only happen when blocks do.

Change-Id: Idd25b2f8a789ba191fde87e997910e78d67c7021

includes/api/ApiQueryBlocks.php
includes/specials/SpecialBlockList.php

index 8b8bd01..5d7c664 100644 (file)
@@ -173,10 +173,8 @@ class ApiQueryBlocks extends ApiQueryBase {
                        $this->addWhereFld( 'ipb_deleted', 0 );
                }
 
-               // Purge expired entries on one in every 10 queries
-               if ( !mt_rand( 0, 10 ) ) {
-                       Block::purgeExpired();
-               }
+               # Filter out expired rows
+               $this->addWhere( 'ipb_expiry > ' . $db->addQuotes( $db->timestamp() ) );
 
                $res = $this->select( __METHOD__ );
 
index 7c7f017..de58762 100644 (file)
@@ -136,8 +136,7 @@ class SpecialBlockList extends SpecialPage {
                                case Block::TYPE_IP:
                                case Block::TYPE_RANGE:
                                        list( $start, $end ) = IP::parseRange( $target );
-                                       $dbr = wfGetDB( DB_SLAVE );
-                                       $conds[] = $dbr->makeList(
+                                       $conds[] = wfGetDB( DB_SLAVE )->makeList(
                                                [
                                                        'ipb_address' => $target,
                                                        Block::getRangeCond( $start, $end )