Do not call purgeExpiredRestrictions on simple page views
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 11 Feb 2015 05:22:39 +0000 (21:22 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 11 Feb 2015 05:24:04 +0000 (05:24 +0000)
* Also cleaned up the on-the-fly expiry check.

bug: T88445
Change-Id: I0f601df978cc7cdd0a0b7861d39e59dae9bdda00

includes/Title.php
includes/specials/SpecialProtectedpages.php
includes/specials/SpecialProtectedtitles.php

index 9a7cd04..4a372fb 100644 (file)
@@ -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 {
index 6749bb0..00e56c1 100644 (file)
@@ -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 );
 
index d25c2c8..dd9198c 100644 (file)
@@ -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;
                }