r27025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r27024‎ | r27025 | r27026 >
Date:20:38, 29 October 2007
Author:gmaxwell
Status:old
Tags:
Comment:
Resolve bug 1405 (http://bugzilla.wikimedia.org/show_bug.cgi?id=1405). New option $wgUseNPPatrol allows for patrolling of new pages for projects where the overall editing rate is too high to make patrolling useful in the general case. This change is based on the patch by Thue Janus Kristensen.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialNewpages.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -622,7 +622,7 @@
623623 */
624624 function view() {
625625 global $wgUser, $wgOut, $wgRequest, $wgContLang;
626 - global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
 626+ global $wgEnableParserCache, $wgStylePath, $wgParser;
627627 global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
628628 $sk = $wgUser->getSkin();
629629
@@ -868,7 +868,7 @@
869869
870870 # If we have been passed an &rcid= parameter, we want to give the user a
871871 # chance to mark this new article as patrolled.
872 - if ( $wgUseRCPatrol && !is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'patrol' ) ) {
 872+ if (!is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'patrol' ) ) {
873873 $wgOut->addHTML(
874874 "<div class='patrollink'>" .
875875 wfMsgHtml( 'markaspatrolledlink',
@@ -1508,18 +1508,38 @@
15091509 }
15101510
15111511 /**
1512 - * Mark this particular edit as patrolled
 1512+ * Mark this particular edit/page as patrolled
15131513 */
15141514 function markpatrolled() {
1515 - global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUser;
 1515+ global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUseNPPatrol, $wgUser;
15161516 $wgOut->setRobotPolicy( 'noindex,nofollow' );
15171517
1518 - # Check RC patrol config. option
1519 - if( !$wgUseRCPatrol ) {
 1518+ # Check patrol config options
 1519+
 1520+ if ( !($wgUseNPPatrol || $wgUseRCPatrol)) {
15201521 $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
 1522+ return;
 1523+ }
 1524+
 1525+ # If we haven't been given an rc_id value, we can't do anything
 1526+ $rcid = (int) $wgRequest->getVal('rcid');
 1527+ $rc = $rcid ? RecentChange::newFromId($rcid) : null;
 1528+ if ( is_null ( $rc ) )
 1529+ {
 1530+ $wgOut->errorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
15211531 return;
15221532 }
 1533+
 1534+ if ( $rc->mAttribs['rc_type'] == RC_NEW && !$wgUseNPPatrol ) {
 1535+ $wgOut->errorpage( 'nppatroldisabled', 'nppatroldisabledtext' );
 1536+ return;
 1537+ }
15231538
 1539+ if ( !$wgUseRCPatrol && $rc->mAttribs['rc_type'] != RC_NEW) {
 1540+ $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
 1541+ return;
 1542+ }
 1543+
15241544 # Check permissions
15251545 $permission_errors = $this->mTitle->getUserPermissionsErrors( 'patrol', $wgUser );
15261546
@@ -1529,19 +1549,15 @@
15301550 return;
15311551 }
15321552
1533 - # If we haven't been given an rc_id value, we can't do anything
1534 - $rcid = $wgRequest->getVal( 'rcid' );
1535 - if( !$rcid ) {
1536 - $wgOut->errorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
1537 - return;
1538 - }
1539 -
15401553 # Handle the 'MarkPatrolled' hook
15411554 if( !wfRunHooks( 'MarkPatrolled', array( $rcid, &$wgUser, false ) ) ) {
15421555 return;
15431556 }
15441557
1545 - $return = SpecialPage::getTitleFor( 'Recentchanges' );
 1558+ #It would be nice to see where the user had actually come from, but for now just guess
 1559+ $returnto = $rc->mAttribs['rc_type'] == RC_NEW ? 'Newpages' : 'Recentchanges';
 1560+ $return = Title::makeTitle( NS_SPECIAL, $returnto );
 1561+
15461562 # If it's left up to us, check that the user is allowed to patrol this edit
15471563 # If the user has the "autopatrol" right, then we'll assume there are no
15481564 # other conditions stopping them doing so
Index: trunk/phase3/includes/SpecialNewpages.php
@@ -50,8 +50,8 @@
5151 }
5252
5353 function getSQL() {
54 - global $wgUser, $wgUseRCPatrol;
55 - $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
 54+ global $wgUser, $wgUseNPPatrol;
 55+ $usepatrol = ( $wgUseNPPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
5656 $dbr = wfGetDB( DB_SLAVE );
5757 list( $recentchanges, $page ) = $dbr->tableNamesN( 'recentchanges', 'page' );
5858
@@ -123,8 +123,8 @@
124124 * @return bool
125125 */
126126 function patrollable( $result ) {
127 - global $wgUser, $wgUseRCPatrol;
128 - return $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) && !$result->patrolled;
 127+ global $wgUser, $wgUseNPPatrol;
 128+ return $wgUseNPPatrol && $wgUser->isAllowed( 'patrol' ) && !$result->patrolled;
129129 }
130130
131131 function feedItemDesc( $row ) {
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2019,6 +2019,9 @@
20202020 /** Use RC Patrolling to check for vandalism */
20212021 $wgUseRCPatrol = true;
20222022
 2023+/** Use new page patrolling to check new pages on special:Newpages */
 2024+$wgUseNPPatrol = true;
 2025+
20232026 /** Set maximum number of results to return in syndication feeds (RSS, Atom) for
20242027 * eg Recentchanges, Newpages. */
20252028 $wgFeedLimit = 50;
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2435,6 +2435,8 @@
24362436 'markedaspatrollederror' => 'Cannot mark as patrolled',
24372437 'markedaspatrollederrortext' => 'You need to specify a revision to mark as patrolled.',
24382438 'markedaspatrollederror-noautopatrol' => 'You are not allowed to mark your own changes as patrolled.',
 2439+'nppatroldisabled' => 'New Pages Patrol disabled',
 2440+'nppatroldisabledtext' => 'The New Pages Patrol feature is currently disabled.',
24392441
24402442 # Patrol log
24412443 'patrol-log-page' => 'Patrol log',

Status & tagging log