From 477a5bf6589d7f634b6250bc826eb78b4a064d0e Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 10 Feb 2015 21:22:39 -0800 Subject: [PATCH] Do not call purgeExpiredRestrictions on simple page views * Also cleaned up the on-the-fly expiry check. bug: T88445 Change-Id: I0f601df978cc7cdd0a0b7861d39e59dae9bdda00 --- includes/Title.php | 16 ---------------- includes/specials/SpecialProtectedpages.php | 7 +------ includes/specials/SpecialProtectedtitles.php | 8 ++------ 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 9a7cd04b22..4a372fb011 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2749,7 +2749,6 @@ class Title { $sources = $getPages ? array() : false; $now = wfTimestampNow(); - $purgeExpired = false; foreach ( $res as $row ) { $expiry = $wgContLang->formatExpiry( $row->pr_expiry, TS_MW ); @@ -2775,14 +2774,8 @@ class Title { } else { $sources = true; } - } else { - // Trigger lazy purge of expired restrictions from the db - $purgeExpired = true; } } - if ( $purgeExpired ) { - Title::purgeExpiredRestrictions(); - } if ( $getPages ) { $this->mCascadeSources = $sources; @@ -2933,7 +2926,6 @@ class Title { if ( count( $rows ) ) { # Current system - load second to make them override. $now = wfTimestampNow(); - $purgeExpired = false; # Cycle through all the restrictions. foreach ( $rows as $row ) { @@ -2953,15 +2945,8 @@ class Title { $this->mRestrictions[$row->pr_type] = explode( ',', trim( $row->pr_level ) ); $this->mCascadeRestriction |= $row->pr_cascade; - } else { - // Trigger a lazy purge of expired restrictions - $purgeExpired = true; } } - - if ( $purgeExpired ) { - Title::purgeExpiredRestrictions(); - } } $this->mRestrictionsLoaded = true; @@ -2999,7 +2984,6 @@ class Title { $this->mRestrictionsExpiry['create'] = $expiry; $this->mRestrictions['create'] = explode( ',', trim( $title_protection['permission'] ) ); } else { // Get rid of the old restrictions - Title::purgeExpiredRestrictions(); $this->mTitleProtection = false; } } else { diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 6749bb0ae8..00e56c1c79 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -39,11 +39,6 @@ class SpecialProtectedpages extends SpecialPage { $this->outputHeader(); $this->getOutput()->addModuleStyles( 'mediawiki.special' ); - // Purge expired entries on one in every 10 queries - if ( !mt_rand( 0, 10 ) ) { - Title::purgeExpiredRestrictions(); - } - $request = $this->getRequest(); $type = $request->getVal( $this->IdType ); $level = $request->getVal( $this->IdLevel ); @@ -495,7 +490,7 @@ class ProtectedPagesPager extends TablePager { function getQueryInfo() { $conds = $this->mConds; $conds[] = 'pr_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) . - 'OR pr_expiry IS NULL'; + ' OR pr_expiry IS NULL'; $conds[] = 'page_id=pr_page'; $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type ); diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index d25c2c837d..dd9198cbc0 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -38,11 +38,6 @@ class SpecialProtectedtitles extends SpecialPage { $this->setHeaders(); $this->outputHeader(); - // Purge expired entries on one in every 10 queries - if ( !mt_rand( 0, 10 ) ) { - Title::purgeExpiredRestrictions(); - } - $request = $this->getRequest(); $type = $request->getVal( $this->IdType ); $level = $request->getVal( $this->IdLevel ); @@ -252,7 +247,8 @@ class ProtectedTitlesPager extends AlphabeticPager { */ function getQueryInfo() { $conds = $this->mConds; - $conds[] = 'pt_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ); + $conds[] = 'pt_expiry > ' . $this->mDb->addQuotes( $this->mDb->timestamp() ) . + ' OR pt_expiry IS NULL'; if ( $this->level ) { $conds['pt_create_perm'] = $this->level; } -- 2.20.1