Legoktm has uploaded a new change for review.

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

Change subject: Don't show patrol links if RCP/NPP are disabled, but file 
patrol isn't
......................................................................

Don't show patrol links if RCP/NPP are disabled, but file patrol isn't

$wgUseFilePatrol only matters for pages in the File namespace, so limit
it to that. Otherwise wikis with RC and NP patrol disabled will have
patrol links show up, but always have the API request fail.

Bug: T125288
Change-Id: Ia91f6ae7ed54627e3e722f41637b1d11626d9806
---
M includes/page/Article.php
1 file changed, 12 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/271148/1

diff --git a/includes/page/Article.php b/includes/page/Article.php
index e81fd96..6e2b4c6 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -1065,10 +1065,12 @@
 
                $outputPage = $this->getContext()->getOutput();
                $user = $this->getContext()->getUser();
+               $title = $this->getTitle();
                $rc = false;
 
-               if ( !$this->getTitle()->quickUserCan( 'patrol', $user )
-                       || !( $wgUseRCPatrol || $wgUseNPPatrol || 
$wgUseFilePatrol )
+               if ( !$title->quickUserCan( 'patrol', $user )
+                       || !( $wgUseRCPatrol || $wgUseNPPatrol
+                               || ( $wgUseFilePatrol && $title->inNamespace( 
NS_FILE ) ) )
                ) {
                        // Patrolling is disabled or the user isn't allowed to
                        return false;
@@ -1083,7 +1085,7 @@
                }
 
                // Check for cached results
-               $key = wfMemcKey( 'unpatrollable-page', 
$this->getTitle()->getArticleID() );
+               $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() 
);
                $cache = ObjectCache::getMainWANInstance();
                if ( $cache->get( $key ) ) {
                        return false;
@@ -1093,7 +1095,7 @@
                $oldestRevisionTimestamp = $dbr->selectField(
                        'revision',
                        'MIN( rev_timestamp )',
-                       array( 'rev_page' => $this->getTitle()->getArticleID() 
),
+                       array( 'rev_page' => $title->getArticleID() ),
                        __METHOD__
                );
 
@@ -1112,8 +1114,8 @@
                                array(
                                        'rc_new' => 1,
                                        'rc_timestamp' => 
$oldestRevisionTimestamp,
-                                       'rc_namespace' => 
$this->getTitle()->getNamespace(),
-                                       'rc_cur_id' => 
$this->getTitle()->getArticleID()
+                                       'rc_namespace' => 
$title->getNamespace(),
+                                       'rc_cur_id' => $title->getArticleID()
                                ),
                                __METHOD__
                        );
@@ -1129,12 +1131,12 @@
                // (with rc_type = RC_LOG, rc_log_type = upload).
                $recentFileUpload = false;
                if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && 
$wgUseFilePatrol
-                       && $this->getTitle()->getNamespace() === NS_FILE ) {
+                       && $title->getNamespace() === NS_FILE ) {
                        // Retrieve timestamp of most recent upload
                        $newestUploadTimestamp = $dbr->selectField(
                                'image',
                                'MAX( img_timestamp )',
-                               array( 'img_name' => 
$this->getTitle()->getDBkey() ),
+                               array( 'img_name' => $title->getDBkey() ),
                                __METHOD__
                        );
                        if ( $newestUploadTimestamp
@@ -1148,7 +1150,7 @@
                                                'rc_log_type' => 'upload',
                                                'rc_timestamp' => 
$newestUploadTimestamp,
                                                'rc_namespace' => NS_FILE,
-                                               'rc_cur_id' => 
$this->getTitle()->getArticleID()
+                                               'rc_cur_id' => 
$title->getArticleID()
                                        ),
                                        __METHOD__,
                                        array( 'USE INDEX' => 'rc_timestamp' )
@@ -1203,7 +1205,7 @@
                }
 
                $link = Linker::linkKnown(
-                       $this->getTitle(),
+                       $title,
                        $markPatrolledMsg->escaped(),
                        array(),
                        array(

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

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

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

Reply via email to