r34822 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34821‎ | r34822 | r34823 >
Date:18:21, 14 May 2008
Author:aaron
Status:old
Tags:
Comment:
* Add depreciation feed (bug 14106)
* Restrict patrolling to set scope (bug 14125)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -32,6 +32,8 @@
3333
3434 # Allowed namespaces of reviewable pages
3535 $wgFlaggedRevsNamespaces = array( NS_MAIN );
 36+# Patrollable namespaces
 37+$wgFlaggedRevsPatrolNamespaces = array( NS_CATEGORY, NS_IMAGE, NS_TEMPLATE );
3638
3739 # Do flagged revs override the default view?
3840 $wgFlaggedRevsOverride = true;
@@ -181,6 +183,9 @@
182184 # Show reviews in recentchanges? Disabled by default, often spammy...
183185 $wgFlaggedRevsLogInRC = false;
184186
 187+# How far the logs for overseeing quality revisions and depreciations go
 188+$wgFlaggedRevsOversightAge = 7 * 24 * 3600;
 189+
185190 # End of configuration variables.
186191 #########
187192
@@ -222,6 +227,9 @@
223228 # To oversee quality revisions
224229 $wgSpecialPages['QualityOversight'] = 'QualityOversight';
225230 $wgAutoloadClasses['QualityOversight'] = $dir . 'FlaggedRevsPage.php';
 231+# To oversee depreciations
 232+$wgSpecialPages['DepreciationOversight'] = 'DepreciationOversight';
 233+$wgAutoloadClasses['DepreciationOversight'] = $dir . 'FlaggedRevsPage.php';
226234
227235 # Remove stand-alone patrolling
228236 $wgHooks['UserGetRights'][] = 'FlaggedRevs::stripPatrolRights';
@@ -289,9 +297,10 @@
290298
291299 function wfInitFlaggedArticle( $output, $article, $title, $user, $request ) {
292300 global $wgFlaggedArticle, $wgHooks;
293 - if( !FlaggedRevs::isPageReviewable($title) )
 301+ # Load when needed
 302+ if( !FlaggedRevs::isPageReviewable($title) && !FlaggedRevs::isPagePatrollable($title) )
294303 return true;
295 - # Initialize and set article hooks
 304+ # Initialize object and set article hooks
296305 $wgFlaggedArticle = new FlaggedArticle( $title );
297306 # Set image version
298307 $wgFlaggedArticle->setImageVersion();
@@ -673,14 +682,15 @@
674683 /**
675684 * @param Title $title
676685 * @param int $rev_id
677 - * @param Database $db, optional
 686+ * @param $flags, GAID_FOR_UPDATE
678687 * @returns mixed (int or false)
 688+ * Get quality of a revision
679689 */
680 - public static function getRevQuality( $title, $rev_id, $db = NULL ) {
681 - $db = $db ? $db : wfGetDB( DB_SLAVE );
 690+ public static function getRevQuality( $title, $rev_id, $flags=0 ) {
 691+ $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
682692 $quality = $db->selectField( 'flaggedrevs',
683693 'fr_quality',
684 - array( 'fr_page_id' => $title->getArticleID(),
 694+ array( 'fr_page_id' => $title->getArticleID( $flags ),
685695 'fr_rev_id' => $rev_id ),
686696 __METHOD__,
687697 array( 'FORCE INDEX' => 'PRIMARY' )
@@ -689,6 +699,18 @@
690700 }
691701
692702 /**
 703+ * @param Title $title
 704+ * @param int $rev_id
 705+ * @param $flags, GAID_FOR_UPDATE
 706+ * @returns bool
 707+ * Useful for quickly pinging to see if a revision is flagged
 708+ */
 709+ public static function revIsFlagged( $title, $rev_id, $flags=0 ) {
 710+ $quality = self::getRevQuality( $title, $rev_id, $flags=0 );
 711+ return ($quality !== false);
 712+ }
 713+
 714+ /**
693715 * Make stable version link and return the css
694716 * @param Title $title
695717 * @param int $rev_id
@@ -992,10 +1014,26 @@
9931015 */
9941016 public static function isPageReviewable( $title ) {
9951017 global $wgFlaggedRevsNamespaces;
996 - # Treat NS_MEDIA as NS_IMAGE
 1018+ # FIXME: Treat NS_MEDIA as NS_IMAGE
9971019 $ns = ( $title->getNamespace() == NS_MEDIA ) ? NS_IMAGE : $title->getNamespace();
9981020 return ( in_array($ns,$wgFlaggedRevsNamespaces) && !$title->isTalkPage() );
9991021 }
 1022+
 1023+ /**
 1024+ * Is this page in patrolable namespace?
 1025+ * @param Title, $title
 1026+ * @return bool
 1027+ */
 1028+ public static function isPagePatrollable( $title ) {
 1029+ global $wgFlaggedRevsPatrolNamespaces;
 1030+ # No collisions!
 1031+ if( self::isPageReviewable($title) ) {
 1032+ return false;
 1033+ }
 1034+ # FIXME: Treat NS_MEDIA as NS_IMAGE
 1035+ $ns = ( $title->getNamespace() == NS_MEDIA ) ? NS_IMAGE : $title->getNamespace();
 1036+ return ( in_array($ns,$wgFlaggedRevsPatrolNamespaces) && !$title->isTalkPage() );
 1037+ }
10001038
10011039 /**
10021040 * @param Article $article
@@ -1913,10 +1951,21 @@
19141952 * are autopatrolled.
19151953 */
19161954 public static function autoMarkPatrolled( $article, $user, $text, $c, $m, $a, $b, $flags, $rev ) {
1917 - if( !$rev )
1918 - return true;
1919 -
1920 - if( !self::isPageReviewable( $article->getTitle() ) && $user->isAllowed('autopatrolother') ) {
 1955+ if( !$rev ) {
 1956+ return true; // NULL edit
 1957+ }
 1958+ $title = $article->getTitle();
 1959+ $patrol = false;
 1960+ // Is the page reviewable?
 1961+ if( self::isPageReviewable($title) ) {
 1962+ $patrol = self::revIsFlagged($title, $rev->getId(), GAID_FOR_UPDATE );
 1963+ // Can this be patrolled?
 1964+ } else if( self::isPagePatrollable($title) ) {
 1965+ $patrol = $user->isAllowed('autopatrolother');
 1966+ } else {
 1967+ $patrol = true; // mark by default
 1968+ }
 1969+ if( $patrol ) {
19211970 $dbw = wfGetDB( DB_MASTER );
19221971 $dbw->update( 'recentchanges',
19231972 array( 'rc_patrolled' => 1 ),
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -499,7 +499,7 @@
500500 public function addPatrolLink( $article, &$outputDone, &$pcache ) {
501501 global $wgRequest, $wgOut, $wgUser, $wgLang;
502502 # For unreviewable pages, allow for basic patrolling
503 - if( !FlaggedRevs::isPageReviewable( $article->getTitle() ) ) {
 503+ if( FlaggedRevs::isPagePatrollable( $article->getTitle() ) ) {
504504 # If we have been passed an &rcid= parameter, we want to give the user a
505505 # chance to mark this new article as patrolled.
506506 $rcid = $wgRequest->getIntOrNull( 'rcid' );
@@ -802,7 +802,7 @@
803803 }
804804 }
805805 // Prepare a change patrol link, if applicable
806 - } else if( $wgUser->isAllowed( 'review' ) ) {
 806+ } else if( FlaggedRevs::isPagePatrollable( $NewRev->getTitle() ) && $wgUser->isAllowed( 'review' ) ) {
807807 // If we've been given an explicit change identifier, use it; saves time
808808 if( $diff->mRcidMarkPatrolled ) {
809809 $rcid = $diff->mRcidMarkPatrolled;
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -243,6 +243,9 @@
244244 'qualityoversight' => 'Quality oversight',
245245 'qualityoversight-list' => 'This page lists recent approvals of quality revisions as well as depreciations of quality revisions.',
246246
 247+ 'depreciationoversight' => 'Depreciation oversight',
 248+ 'depreciationoversight-list' => 'This page lists recent depreciations of revisions.',
 249+
247250 'rights-editor-autosum' => 'autopromoted',
248251 'rights-editor-revoke' => 'removed editor status from [[$1]]',
249252
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -1671,12 +1671,12 @@
16721672 }
16731673
16741674 function execute( $par ) {
1675 - global $wgOut, $wgUser, $wgRCMaxAge;
 1675+ global $wgOut, $wgUser, $wgFlaggedRevsOversightAge;
16761676 $this->setHeaders();
16771677 $wgOut->addHTML( wfMsgExt('qualityoversight-list', array('parse') ) );
16781678 # Create a LogPager item to get the results and a LogEventsList
16791679 # item to format them...
1680 - $cutoff = time() - $wgRCMaxAge;
 1680+ $cutoff = time() - $wgFlaggedRevsOversightAge;
16811681 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
16821682 $pager = new LogPager( $loglist, 'review', '', '', '',
16831683 array('log_action' => array('approve2','unapprove2'), "log_timestamp > '$cutoff'" ) );
@@ -1695,3 +1695,35 @@
16961696 }
16971697 }
16981698 }
 1699+
 1700+class DepreciationOversight extends SpecialPage
 1701+{
 1702+ function __construct() {
 1703+ SpecialPage::SpecialPage( 'DepreciationOversight' );
 1704+ }
 1705+
 1706+ function execute( $par ) {
 1707+ global $wgOut, $wgUser, $wgFlaggedRevsOversightAge;
 1708+ $this->setHeaders();
 1709+ $wgOut->addHTML( wfMsgExt('depreciationoversight-list', array('parse') ) );
 1710+ # Create a LogPager item to get the results and a LogEventsList
 1711+ # item to format them...
 1712+ $cutoff = time() - $wgFlaggedRevsOversightAge;
 1713+ $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
 1714+ $pager = new LogPager( $loglist, 'review', '', '', '',
 1715+ array('log_action' => array('unapprove','unapprove2'), "log_timestamp > '$cutoff'" ) );
 1716+ # Insert list
 1717+ $logBody = $pager->getBody();
 1718+ if( $logBody ) {
 1719+ $wgOut->addHTML(
 1720+ $pager->getNavigationBar() .
 1721+ $loglist->beginLogEventsList() .
 1722+ $logBody .
 1723+ $loglist->endLogEventsList() .
 1724+ $pager->getNavigationBar()
 1725+ );
 1726+ } else {
 1727+ $wgOut->addWikiMsg( 'logempty' );
 1728+ }
 1729+ }
 1730+}

Status & tagging log