From: addshore Date: Fri, 22 Dec 2017 16:39:00 +0000 (+0000) Subject: [MCR] Revision::newFromArchiveRow convert overrides for rows X-Git-Tag: 1.31.0-rc.0~1123 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=e85046bb4a37f8c06464c2dfa50fd474695d3ae3;p=lhc%2Fweb%2Fwiklou.git [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 --- diff --git a/includes/Revision.php b/includes/Revision.php index f3307c64b3..ed0646afd1 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -148,6 +148,17 @@ class Revision implements IDBAccessObject { * @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 50ae8d57d9..341855dbe3 100644 --- a/includes/Storage/RevisionStoreRecord.php +++ b/includes/Storage/RevisionStoreRecord.php @@ -97,7 +97,8 @@ class RevisionStoreRecord extends RevisionRecord { && $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() ); } }