From: Nathaniel Herman Date: Sat, 7 Mar 2009 23:01:59 +0000 (+0000) Subject: (bug 10336) Added new magic word {{REVISIONUSER}}, which displays the user name of... X-Git-Tag: 1.31.0-rc.0~42573 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=df7ba5f52c718f94d9f8aa33052d114c0334777e;p=lhc%2Fweb%2Fwiklou.git (bug 10336) Added new magic word {{REVISIONUSER}}, which displays the user name of the last user to edit the page --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4238028f09..7b37b3612a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -132,6 +132,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (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. diff --git a/includes/MagicWord.php b/includes/MagicWord.php index fcd6b0343d..4e97016dde 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -78,6 +78,7 @@ class MagicWord { 'revisionmonth', 'revisionyear', 'revisiontimestamp', + 'revisionuser', 'subpagename', 'subpagenamee', 'displaytitle', diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index c94cf2ef57..33bfbd82fa 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2450,6 +2450,12 @@ class Parser $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': @@ -4625,6 +4631,23 @@ class Parser return $this->mRevisionTimestamp; } + /** + * 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 * diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 0c3e91263a..a1f84ddf0a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -300,6 +300,7 @@ $magicWords = array( '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:' ),