Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399838 )

Change subject: [MCR] Revision::newFromArchiveRow convert overrides for rows
......................................................................

[MCR] Revision::newFromArchiveRow convert overrides for rows

This method used to overwrite attributes, then passed to
Revision::__construct
RevisionStore::newRevisionFromArchiveRow instead overrides row field
names

This patch adds a conversion for the one field that we need to care
about which is 'page' -> 'page_id'.

After looking through the usages in core and extensions it looks
like this will also fix a bug in the following classes which also
passes in 'page'.
 - RevDelArchivedRevisionItem
 - RevDelArchiveItem

Bug: T183564
Change-Id: I6a472b93663a0599abb55453c6939463ff56275d
---
M includes/Revision.php
M includes/Storage/RevisionStoreRecord.php
2 files changed, 13 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/38/399838/1

diff --git a/includes/Revision.php b/includes/Revision.php
index f3307c6..ed0646a 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -148,6 +148,17 @@
         * @return Revision
         */
        public static function newFromArchiveRow( $row, $overrides = [], Title 
$title = null ) {
+               /**
+                * MCR Migration: https://phabricator.wikimedia.org/T183564
+                * This method used to overwrite attributes, then passed to 
Revision::__construct
+                * RevisionStore::newRevisionFromArchiveRow instead overrides 
row field names
+                * So do a conversion here.
+                */
+               if ( array_key_exists( 'page', $overrides ) ) {
+                       $overrides['page_id'] = $overrides['page'];
+                       unset( $overrides['page'] );
+               }
+
                $rec = self::getRevisionStore()->newRevisionFromArchiveRow( 
$row, 0, $title, $overrides );
                return new Revision( $rec, self::READ_NORMAL, $title );
        }
diff --git a/includes/Storage/RevisionStoreRecord.php 
b/includes/Storage/RevisionStoreRecord.php
index 50ae8d5..341855d 100644
--- a/includes/Storage/RevisionStoreRecord.php
+++ b/includes/Storage/RevisionStoreRecord.php
@@ -97,7 +97,8 @@
                        && $this->mPageId !== $this->mTitle->getArticleID()
                ) {
                        throw new InvalidArgumentException(
-                               'The given Title does not belong to page ID ' . 
$this->mPageId
+                               'The given Title does not belong to page ID ' . 
$this->mPageId .
+                               ' but actually belongs to ' . 
$this->mTitle->getArticleID()
                        );
                }
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a472b93663a0599abb55453c6939463ff56275d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to