jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/400605 )

Change subject: [MCR] Revision::newFromArchiveRow remove recently added $title 
param
......................................................................


[MCR] Revision::newFromArchiveRow remove recently added $title param

The $title param was added as part of
Ieabca1cf157fb667c75fc907b9da2917f71c61b3 and is not yet used
by any code.

The underlying issue with title fetching in RevisionStore has been fixed
in commit 4de36baa63afc23398f5d1747f08fc47309c314c
I15e4663902e2cbfe15b0da2e46449330e313bd0d

This patch removes the param that is not needed, but adds duplicate
logic to fetch a Title object to pass into the Revision object that
is created.
This logic is pulled directly from
RevisionStore::newRevisionFromArchiveRow.

Change-Id: I60568b8ffd22d5e3f861c03b4b8ef14332e9015b
---
M includes/Revision.php
1 file changed, 25 insertions(+), 2 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Revision.php b/includes/Revision.php
index 7d38b4e..4058c63 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -149,7 +149,7 @@
         * @throws MWException
         * @return Revision
         */
-       public static function newFromArchiveRow( $row, $overrides = [], Title 
$title = null ) {
+       public static function newFromArchiveRow( $row, $overrides = [] ) {
                /**
                 * MCR Migration: https://phabricator.wikimedia.org/T183564
                 * This method used to overwrite attributes, then passed to 
Revision::__construct
@@ -161,7 +161,30 @@
                        unset( $overrides['page'] );
                }
 
-               $rec = self::getRevisionStore()->newRevisionFromArchiveRow( 
$row, 0, $title, $overrides );
+               /**
+                * We require a Title for both the Revision object and the 
RevisionRecord.
+                * Below is duplicated logic from 
RevisionStore::newRevisionFromArchiveRow
+                * to fetch a title in order pass it into the Revision object.
+                */
+               $title = null;
+               if ( isset( $overrides['title'] ) ) {
+                       if ( !( $overrides['title'] instanceof Title ) ) {
+                               throw new MWException( 'title field override 
must contain a Title object.' );
+                       }
+
+                       $title = $overrides['title'];
+               }
+               if ( $title !== null ) {
+                       if ( isset( $row->ar_namespace ) && isset( 
$row->ar_title ) ) {
+                               $title = Title::makeTitle( $row->ar_namespace, 
$row->ar_title );
+                       } else {
+                               throw new InvalidArgumentException(
+                                       'A Title or ar_namespace and ar_title 
must be given'
+                               );
+                       }
+               }
+
+               $rec = self::getRevisionStore()->newRevisionFromArchiveRow( 
$row, 0, null, $overrides );
                return new Revision( $rec, self::READ_NORMAL, $title );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/400605
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I60568b8ffd22d5e3f861c03b4b8ef14332e9015b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to