r48149 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r48148 | r48149 (on ViewVC) | r48150 >
Date:23:01, 7 March 2009
Author:pinky
Status:resolved (Comments)
Tags:
Comment:(bug 10336) Added new magic word {{REVISIONUSER}}, which displays the user name of the last user to edit the page
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php	(revision 48148)
+++ trunk/phase3/includes/parser/Parser.php	(revision 48149)
@@ -2450,6 +2450,12 @@
 				$this->mOutput->setFlag( 'vary-revision' );
 				wfDebug( __METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n" );
 				return $this->getRevisionTimestamp();
+			case 'revisionuser':
+                                // Let the edit saving system know we should parse the page
+                                // *after* a revision ID has been assigned. This is for null edits.
+				$this->mOutput->setFlag( 'vary-revision' );
+				wfDebug( __METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n" );
+				return $this->getRevisionUser();
 			case 'namespace':
 				return str_replace('_',' ',$wgContLang->getNsText( $this->mTitle->getNamespace() ) );
 			case 'namespacee':
@@ -4626,6 +4632,23 @@
 	}
 
 	/**
+	 * Get the name of the user that edited the last revision
+	 */
+	function getRevisionUser() {
+		// if this template is subst: the revision id will be blank,
+		// so just use the current user's name
+		if( $this->mRevisionId ) {
+	                $dbr = wfGetDB( DB_SLAVE );
+	                $revuser = $dbr->selectField( 'revision', 'rev_user_text',
+ 				array( 'rev_id' => $this->mRevisionId ), __METHOD__ );
+		} else {
+			global $wgUser;
+			$revuser = $wgUser->getName();
+		}
+		return $revuser;
+	}
+
+	/**
 	 * Mutator for $mDefaultSort
 	 *
 	 * @param $sort New value
Index: trunk/phase3/includes/MagicWord.php
===================================================================
--- trunk/phase3/includes/MagicWord.php	(revision 48148)
+++ trunk/phase3/includes/MagicWord.php	(revision 48149)
@@ -78,6 +78,7 @@
 		'revisionmonth',
 		'revisionyear',
 		'revisiontimestamp',
+		'revisionuser',
 		'subpagename',
 		'subpagenamee',
 		'displaytitle',
Index: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php	(revision 48148)
+++ trunk/phase3/languages/messages/MessagesEn.php	(revision 48149)
@@ -300,6 +300,7 @@
 	'revisionmonth'          => array( 1,    'REVISIONMONTH'          ),
 	'revisionyear'           => array( 1,    'REVISIONYEAR'           ),
 	'revisiontimestamp'      => array( 1,    'REVISIONTIMESTAMP'      ),
+	'revisionuser'           => array( 1,    'REVISIONUSER'           ),
 	'plural'                 => array( 0,    'PLURAL:'                ),
 	'fullurl'                => array( 0,    'FULLURL:'               ),
 	'fullurle'               => array( 0,    'FULLURLE:'              ),
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 48148)
+++ trunk/phase3/RELEASE-NOTES	(revision 48149)
@@ -132,6 +132,8 @@
 * (bug 17844) Redirect users to a specific page when they log in, see 
   $wgRedirectOnLogin
 * Added a link to Special:UserRights on Special:Contributions for privileged users
+* (bug 10336) Added new magic word {{REVISIONUSER}}, which displays the user
+  name of the last user to edit the page
 
 === Bug fixes in 1.15 ===
 * (bug 16968) Special:Upload no longer throws useless warnings.

Follow-up revisions

RevisionCommit summaryAuthorDate
r48334Follow up on r48149, update RELEASE-NOTESpinky23:02, 11 March 2009

Comments

#Comment by Aaron Schulz (Talk | contribs)   05:03, 8 March 2009

RELEASE-NOTES look wrong, should be "edit of this revision" not "last editor"

#Comment by Pinky (Talk | contribs)   00:50, 10 March 2009
  • (bug 10336) Added new magic word 38.107.191.102, which displays the editor of the current revision's user name -- better?
#Comment by Pinky (Talk | contribs)   23:04, 11 March 2009

Updated in r48334

#Comment by Jack Phoenix (Talk | contribs)   23:04, 11 March 2009

Resolved in r48334.

Status & tagging log

Views
Toolbox