[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
This commit is contained in:
parent
df015f95c9
commit
e85046bb4a
2 changed files with 13 additions and 1 deletions
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue