Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189905

Change subject: Do not call purgeExpiredRestrictions on simple page views
......................................................................

Do not call purgeExpiredRestrictions on simple page views

* Also cleaned up the on-the-fly expiry check.

Change-Id: I0f601df978cc7cdd0a0b7861d39e59dae9bdda00
---
M includes/Title.php
M includes/specials/SpecialProtectedpages.php
M includes/specials/SpecialProtectedtitles.php
3 files changed, 3 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/189905/1

diff --git a/includes/Title.php b/includes/Title.php
index 9a7cd04..4a372fb 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2749,7 +2749,6 @@
 
                $sources = $getPages ? array() : false;
                $now = wfTimestampNow();
-               $purgeExpired = false;
 
                foreach ( $res as $row ) {
                        $expiry = $wgContLang->formatExpiry( $row->pr_expiry, 
TS_MW );
@@ -2775,13 +2774,7 @@
                                } else {
                                        $sources = true;
                                }
-                       } else {
-                               // Trigger lazy purge of expired restrictions 
from the db
-                               $purgeExpired = true;
                        }
-               }
-               if ( $purgeExpired ) {
-                       Title::purgeExpiredRestrictions();
                }
 
                if ( $getPages ) {
@@ -2933,7 +2926,6 @@
                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,14 +2945,7 @@
                                        $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();
                        }
                }
 
@@ -2999,7 +2984,6 @@
                                                
$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 6749bb0..00e56c1 100644
--- a/includes/specials/SpecialProtectedpages.php
+++ b/includes/specials/SpecialProtectedpages.php
@@ -39,11 +39,6 @@
                $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 @@
        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 d25c2c8..dd9198c 100644
--- a/includes/specials/SpecialProtectedtitles.php
+++ b/includes/specials/SpecialProtectedtitles.php
@@ -38,11 +38,6 @@
                $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 @@
         */
        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;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/189905
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f601df978cc7cdd0a0b7861d39e59dae9bdda00
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to