From 0bf5f49f14dce286f0ef9d573fa77a01b01ba20f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 28 Aug 2016 11:37:39 -0700 Subject: [PATCH] Remove Block::purgeExpired() call from block query API 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 | 6 ++---- includes/specials/SpecialBlockList.php | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 8b8bd0110f..5d7c664aac 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -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__ ); diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index 7c7f017b72..de58762a7e 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -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 ) -- 2.20.1