r36342 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36341‎ | r36342 | r36343 >
Date:19:16, 16 June 2008
Author:aaron
Status:old
Tags:
Comment:
* Show diff to prior stable (at time) in log (bug 14265)
* Add more log actions for sorting
* Remove some duplication
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -361,21 +361,26 @@
362362 $wgUseRCPatrol = true;
363363 }
364364
365 -# Add review log and such
 365+# Add review log
366366 $wgLogTypes[] = 'review';
367367 $wgLogNames['review'] = 'review-logpage';
368368 $wgLogHeaders['review'] = 'review-logpagetext';
369 -$wgLogActions['review/approve'] = 'review-logentry-app';
370 -$wgLogActions['review/approve2'] = 'review-logentry-app';
371 -$wgLogActions['review/unapprove'] = 'review-logentry-dis';
372 -$wgLogActions['review/unapprove2'] = 'review-logentry-dis';
 369+# Various actions are used for log filtering ...
 370+$wgLogActions['review/approve'] = 'review-logentry-app'; // sighted
 371+$wgLogActions['review/approve2'] = 'review-logentry-app'; // quality
 372+$wgLogActions['review/approve-a'] = 'review-logentry-app'; // sighted (auto)
 373+$wgLogActions['review/approve2-a'] = 'review-logentry-app'; // quality (auto)
 374+$wgLogActions['review/unapprove'] = 'review-logentry-dis'; // was sighted
 375+$wgLogActions['review/unapprove2'] = 'review-logentry-dis'; // was quality
373376
 377+# Add stable version log
374378 $wgLogTypes[] = 'stable';
375379 $wgLogNames['stable'] = 'stable-logpage';
376380 $wgLogHeaders['stable'] = 'stable-logpagetext';
377381 $wgLogActions['stable/config'] = 'stable-logentry';
378382 $wgLogActions['stable/reset'] = 'stable-logentry2';
379383
 384+# B/C ...
380385 $wgLogActions['rights/erevoke'] = 'rights-editor-revoke';
381386
382387 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efFlaggedRevsSchemaUpdates';
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -886,6 +886,11 @@
887887 $latestID = $latestID ? $latestID : $rev->getId(); // new pages, page row not added yet
888888
889889 $title = $article->getTitle();
 890+
 891+ # Get current stable version ID (for logging)
 892+ $oldSv = FlaggedRevision::newFromStable( $title, false, true );
 893+ $oldSvId = $oldSv ? $oldSv->getRevId() : 0;
 894+
890895 # Rev ID is not put into parser on edit, so do the same here.
891896 # Also, a second parse would be triggered otherwise.
892897 $parseId = ($rev->getId() == $latestID) ? null : $rev->getId();
@@ -1008,7 +1013,7 @@
10091014 $dbw->commit();
10101015
10111016 # Update the article review log
1012 - RevisionReview::updateLog( $title, $flags, array(), wfMsgForContent('revreview-auto'), $rev->getID(), true, true );
 1017+ RevisionReview::updateLog( $title, $flags, array(), '', $rev->getId(), $oldSvId, true, true );
10131018
10141019 # If we know that this is now the new stable version
10151020 # (which it probably is), save it to the cache...
@@ -1968,15 +1973,18 @@
19691974 * @return bool true
19701975 */
19711976 public static function reviewLogLine( $type = '', $action = '', $title = null, $paramArray = array(), &$c = '', &$r = '', $t = '' ) {
 1977+ $actionsValid = array('approve','approve2','approve-a','approve2-a','unapprove','unapprove2');
19721978 # Show link to page with oldid=x
1973 - if( $type == 'review' && in_array($action,array('approve','approve2','unapprove','unapprove2')) ) {
 1979+ if( $type == 'review' && in_array($action,$actionsValid) && is_object($title) && isset($paramArray[0]) ) {
19741980 global $wgUser;
1975 - if( is_object($title) && isset($paramArray[0]) ) {
1976 - $r = '(' . $wgUser->getSkin()->makeKnownLinkObj( $title,
1977 - wfMsgHtml('diff'), "oldid={$paramArray[0]}&diff=prev") . ')';
1978 - $r .= ' (' . $wgUser->getSkin()->makeKnownLinkObj( $title,
1979 - wfMsgHtml('review-logentry-id',$paramArray[0]), "oldid={$paramArray[0]}") . ')';
 1981+ if( !empty($paramArray[1]) ) {
 1982+ $r = '(' . $wgUser->getSkin()->makeKnownLinkObj( $title, wfMsgHtml('review-logentry-diff'),
 1983+ "oldid={$paramArray[1]}&diff={$paramArray[0]}") . ')';
 1984+ } else {
 1985+ $r = '(' . wfMsgHtml('review-logentry-diff') . ')';
19801986 }
 1987+ $r .= ' (' . $wgUser->getSkin()->makeKnownLinkObj( $title,
 1988+ wfMsgHtml('review-logentry-id',$paramArray[0]), "oldid={$paramArray[0]}&diff=prev") . ')';
19811989 }
19821990 return true;
19831991 }
Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php
@@ -34,6 +34,7 @@
3535 'review-logentry-app' => 'reviewed [[$1]]',
3636 'review-logentry-dis' => 'depreciated a version of [[$1]]',
3737 'review-logentry-id' => 'revision ID $1',
 38+ 'review-logentry-diff' => 'diff to stable',
3839 'review-logpage' => 'Review log',
3940 'review-logpagetext' => 'This is a log of changes to revisions\' [[{{MediaWiki:Validationpage}}|approval]] status for content pages.
4041 See the [[Special:ReviewedPages|reviewed pages list]] for a list of approved pages.',
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -495,6 +495,10 @@
496496 }
497497
498498 $article = new Article( $this->page );
 499+ # Get current stable version ID (for logging)
 500+ $oldSv = FlaggedRevision::newFromStable( $this->page, false, true );
 501+ $oldSvId = $oldSv ? $oldSv->getRevId() : 0;
 502+
499503 # Is this rev already flagged?
500504 $flaggedOutput = false;
501505 if( $oldfrev = FlaggedRevision::newFromTitle( $title, $rev->getId(), true, true ) ) {
@@ -613,7 +617,7 @@
614618 $this->updateRecentChanges( $title, $dbw, $rev, $this->rcid );
615619
616620 # Update the article review log
617 - $this->updateLog( $this->page, $this->dims, $this->oflags, $this->comment, $this->oldid, true );
 621+ $this->updateLog( $this->page, $this->dims, $this->oflags, $this->comment, $this->oldid, $oldSvId, true );
618622
619623 # Update the links tables as the stable version may now be the default page.
620624 # Try using the parser cache first since we didn't actually edit the current version.
@@ -662,6 +666,10 @@
663667 global $wgUser, $wgParser, $wgRevisionCacheExpiry, $wgMemc;
664668 wfProfileIn( __METHOD__ );
665669
 670+ # Get current stable version ID (for logging)
 671+ $oldSv = FlaggedRevision::newFromStable( $this->page, false, true );
 672+ $oldSvId = $oldSv ? $oldSv->getRevId() : 0;
 673+
666674 $dbw = wfGetDB( DB_MASTER );
667675 $dbw->begin();
668676 # Delete from flaggedrevs table
@@ -673,7 +681,7 @@
674682 $dbw->commit();
675683
676684 # Update the article review log
677 - $this->updateLog( $this->page, $this->dims, $this->oflags, $this->comment, $this->oldid, false );
 685+ $this->updateLog( $this->page, $this->dims, $this->oflags, $this->comment, $this->oldid, $oldSvId, false );
678686
679687 # Kill any text cache
680688 if( $wgRevisionCacheExpiry ) {
@@ -770,14 +778,14 @@
771779 * @param array $dims
772780 * @param array $oldDims
773781 * @param string $comment
774 - * @param int $revid
775 - * @param bool $approve
 782+ * @param int $revId, revision ID
 783+ * @param int $sId, prior stable revision ID
 784+ * @param bool $approve, approved? (otherwise unapproved)
776785 * @param bool $auto
777786 */
778 - public static function updateLog( $title, $dims, $oldDims, $comment, $oldid, $approve, $auto=false ) {
 787+ public static function updateLog( $title, $dims, $oldDims, $comment, $revId, $stableId, $approve, $auto=false ) {
779788 global $wgFlaggedRevsLogInRC;
780 - $putInRC = $auto ? false : $wgFlaggedRevsLogInRC; // don't put these in RC
781 - $log = new LogPage( 'review', $putInRC );
 789+ $log = new LogPage( 'review', ($auto ? false : $wgFlaggedRevsLogInRC) );
782790 # ID, accuracy, depth, style
783791 $ratings = array();
784792 foreach( $dims as $quality => $level ) {
@@ -785,15 +793,17 @@
786794 }
787795 # Append comment with ratings
788796 if( $approve ) {
 797+ $comment = $auto ? wfMsgForContent('revreview-auto') : $comment; // override this
789798 $rating = !empty($ratings) ? '[' . implode(', ',$ratings). ']' : '';
790799 $comment .= $comment ? " $rating" : $rating;
791800 }
 801+ # Sort into the proper action (useful for filtering)
792802 if( $approve ) {
793803 $action = (FlaggedRevs::isQuality($dims) || FlaggedRevs::isQuality($oldDims)) ? 'approve2' : 'approve';
794 - $log->addEntry( $action, $title, $comment, array($oldid) );
 804+ $action .= $auto ? "-a" : "";
795805 } else {
796806 $action = FlaggedRevs::isQuality($oldDims) ? 'unapprove2' : 'unapprove';
797 - $log->addEntry( $action, $title, $comment, array($oldid) );
798807 }
 808+ $log->addEntry( $action, $title, $comment, array($revId,$stableId) );
799809 }
800810 }

Status & tagging log