(bug 10336) Added new magic word {{REVISIONUSER}}, which displays the user name of...
authorNathaniel Herman <pinky@users.mediawiki.org>
Sat, 7 Mar 2009 23:01:59 +0000 (23:01 +0000)
committerNathaniel Herman <pinky@users.mediawiki.org>
Sat, 7 Mar 2009 23:01:59 +0000 (23:01 +0000)
RELEASE-NOTES
includes/MagicWord.php
includes/parser/Parser.php
languages/messages/MessagesEn.php

index 4238028..7b37b36 100644 (file)
@@ -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.
index fcd6b03..4e97016 100644 (file)
@@ -78,6 +78,7 @@ class MagicWord {
                'revisionmonth',
                'revisionyear',
                'revisiontimestamp',
+               'revisionuser',
                'subpagename',
                'subpagenamee',
                'displaytitle',
index c94cf2e..33bfbd8 100644 (file)
@@ -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
         *
index 0c3e912..a1f84dd 100644 (file)
@@ -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:'              ),