Add $user param to Revision::newNullRevision
authorumherirrender <umherirrender_de.wp@web.de>
Mon, 28 Apr 2014 16:59:20 +0000 (18:59 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Mon, 28 Apr 2014 16:59:20 +0000 (18:59 +0200)
This avoids the use of $wgUser in Revision constructor and makes the
dependency on the global visible.

Change-Id: Ib67bd706a3c4ef081f475406e9aa1094c42222ef

includes/Revision.php
includes/Title.php
includes/WikiPage.php
includes/filerepo/file/LocalFile.php
includes/specials/SpecialImport.php

index 7b30540..afbd3ac 100644 (file)
@@ -1566,9 +1566,10 @@ class Revision implements IDBAccessObject {
         * @param int $pageId: ID number of the page to read from
         * @param string $summary Revision's summary
         * @param bool $minor Whether the revision should be considered as minor
+        * @param User|null $user User object to use or null for $wgUser
         * @return Revision|null Revision or null on error
         */
-       public static function newNullRevision( $dbw, $pageId, $summary, $minor ) {
+       public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
                global $wgContentHandlerUseDB;
 
                wfProfileIn( __METHOD__ );
@@ -1591,8 +1592,15 @@ class Revision implements IDBAccessObject {
                        __METHOD__ );
 
                if ( $current ) {
+                       if ( !$user ) {
+                               global $wgUser;
+                               $user = $wgUser;
+                       }
+
                        $row = array(
                                'page'       => $pageId,
+                               'user_text'  => $user->getName(),
+                               'user'       => $user->getId(),
                                'comment'    => $summary,
                                'minor_edit' => $minor,
                                'text_id'    => $current->rev_text_id,
index 4dc0372..eec4dd6 100644 (file)
@@ -3859,7 +3859,7 @@ class Title {
                }
 
                # Save a null revision in the page's history notifying of the move
-               $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
+               $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true, $wgUser );
                if ( !is_object( $nullRevision ) ) {
                        throw new MWException( 'No valid null revision produced in ' . __METHOD__ );
                }
index 8e15ac9..161125d 100644 (file)
@@ -2407,7 +2407,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                        // insert null revision to identify the page protection change as edit summary
                        $latest = $this->getLatest();
-                       $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason );
+                       $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason, $user );
                        if ( $nullRevision === null ) {
                                return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() );
                        }
@@ -2506,9 +2506,10 @@ class WikiPage implements Page, IDBAccessObject {
         * @param array $expiry Per restriction type expiration
         * @param int $cascade Set to false if cascading protection isn't allowed.
         * @param string $reason
+        * @param User|null $user
         * @return Revision|null Null on error
         */
-       public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason ) {
+       public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user = null ) {
                global $wgContLang;
                $dbw = wfGetDB( DB_MASTER );
 
@@ -2534,7 +2535,7 @@ class WikiPage implements Page, IDBAccessObject {
                        )->inContentLanguage()->text();
                }
 
-               $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true );
+               $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true, $user );
                if ( $nullRev ) {
                        $nullRev->insertOn( $dbw );
 
index e3b73e3..5bc7b5e 100644 (file)
@@ -1424,7 +1424,8 @@ class LocalFile extends File {
                                $dbw,
                                $descTitle->getArticleID(),
                                $editSummary,
-                               false
+                               false,
+                               $user
                        );
                        if ( !is_null( $nullRevision ) ) {
                                $nullRevision->insertOn( $dbw );
index aca8c96..891962b 100644 (file)
@@ -492,7 +492,7 @@ class ImportReporter extends ContextSource {
                        $comment = $detail; // quick
                        $dbw = wfGetDB( DB_MASTER );
                        $latest = $title->getLatestRevID();
-                       $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleID(), $comment, true );
+                       $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleID(), $comment, true, $this->getUser() );
                        if ( !is_null( $nullRevision ) ) {
                                $nullRevision->insertOn( $dbw );
                                $page = WikiPage::factory( $title );