diff --git a/RELEASE-NOTES-1.35 b/RELEASE-NOTES-1.35 index 0eb49c3852f..81403746b18 100644 --- a/RELEASE-NOTES-1.35 +++ b/RELEASE-NOTES-1.35 @@ -1204,6 +1204,10 @@ because of Phabricator reports. * Parser::statelessFetchTemplate returns an array; accessing the Revision object returned (via the `revision` key to the array) is deprecated. Instead, use `revision-record` to retrieve the equivalent RevisionRecord. +* WikiPage::doEditContent returns an array, and PageUpdater::getStatus returns + a Status object with an array value. For both of those arrays, accessing the + Revision object returned (via the `revision` key to the array) is deprecated. + Instead, use `revision-record` to retrieve the equivalent RevisionRecord. * Page interface was deprecated. Use Article or WikiPage instead. * The following DatabaseBlock methods are deprecated because they are no longer needed in core: chooseBlock, fromMaster, deleteIfExpired. diff --git a/includes/Storage/PageUpdater.php b/includes/Storage/PageUpdater.php index 0c60ac26510..a504413f1ed 100644 --- a/includes/Storage/PageUpdater.php +++ b/includes/Storage/PageUpdater.php @@ -1003,7 +1003,7 @@ class PageUpdater { $status = Status::newGood( new DeprecatablePropertyArray( [ 'new' => false, 'revision' => null, 'revision-record' => null ], - [], // TODO: [ 'revision' => '1.35' ], + [ 'revision' => '1.35' ], __METHOD__ . ' status' ) ); @@ -1109,8 +1109,10 @@ class PageUpdater { // Return the new revision to the caller $status->value['revision-record'] = $newRevisionRecord; - // TODO: globally replace usages of 'revision' with getNewRevision() - $status->value['revision'] = $newLegacyRevision; + // Deprecated via DeprecatablePropertyArray + $status->value['revision'] = function () use ( $newRevisionRecord ) { + return new Revision( $newRevisionRecord ); + }; } else { // T34948: revision ID must be set to page {{REVISIONID}} and // related variables correctly. Likewise for {{REVISIONUSER}} (T135261). @@ -1167,7 +1169,7 @@ class PageUpdater { $status = Status::newGood( new DeprecatablePropertyArray( [ 'new' => true, 'revision' => null, 'revision-record' => null ], - [], // TODO: [ 'revision' => '1.35' ], + [ 'revision' => '1.35' ], __METHOD__ . ' status' ) ); @@ -1262,10 +1264,13 @@ class PageUpdater { $dbw->endAtomic( __METHOD__ ); // Return the new revision to the caller - // TODO: globally replace usages of 'revision' with getNewRevision() - $status->value['revision'] = $newLegacyRevision; $status->value['revision-record'] = $newRevisionRecord; + // Deprecated via DeprecatablePropertyArray + $status->value['revision'] = function () use ( $newRevisionRecord ) { + return new Revision( $newRevisionRecord ); + }; + // Do secondary updates once the main changes have been committed... DeferredUpdates::addUpdate( $this->getAtomicSectionUpdate( diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 734116b68f9..c077d08383e 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1921,7 +1921,9 @@ class WikiPage implements Page, IDBAccessObject { * * $return->value will contain an associative array with members as follows: * new: Boolean indicating if the function attempted to create a new article. - * revision: The revision object for the inserted revision, or null. + * revision: The revision object for the inserted revision, or null. Trying to access + * this Revision object is deprecated since 1.35 + * revision-record: The RevisionRecord object for the inserted revision, or null. * * @since 1.21 * @throws MWException diff --git a/tests/phpunit/includes/EditPageTest.php b/tests/phpunit/includes/EditPageTest.php index 290bba9112b..1b23bc86734 100644 --- a/tests/phpunit/includes/EditPageTest.php +++ b/tests/phpunit/includes/EditPageTest.php @@ -291,7 +291,7 @@ class EditPageTest extends MediaWikiLangTestCase { $summary, $minor, $u1, $u2, &$flags, Revision $revision, Status &$status, $baseRevId ) use ( &$checkId ) { - $checkId = $status->value['revision']->getId(); + $checkId = $status->value['revision-record']->getId(); // types/refs checked } ], ] ); @@ -332,7 +332,7 @@ class EditPageTest extends MediaWikiLangTestCase { $summary, $minor, $u1, $u2, &$flags, Revision $revision, Status &$status, $baseRevId ) use ( &$checkIds ) { - $checkIds[] = $status->value['revision']->getId(); + $checkIds[] = $status->value['revision-record']->getId(); // types/refs checked } ], ] ); @@ -388,7 +388,7 @@ class EditPageTest extends MediaWikiLangTestCase { $summary, $minor, $u1, $u2, &$flags, Revision $revision, Status &$status, $baseRevId ) use ( &$checkIds ) { - $checkIds[] = $status->value['revision']->getId(); + $checkIds[] = $status->value['revision-record']->getId(); // types/refs checked } ], ] ); @@ -442,7 +442,7 @@ class EditPageTest extends MediaWikiLangTestCase { $summary, $minor, $u1, $u2, &$flags, Revision $revision, Status &$status, $baseRevId ) use ( &$checkIds ) { - $checkIds[] = $status->value['revision']->getId(); + $checkIds[] = $status->value['revision-record']->getId(); // types/refs checked } ], ] ); diff --git a/tests/phpunit/includes/Storage/PageUpdaterTest.php b/tests/phpunit/includes/Storage/PageUpdaterTest.php index 8ddec347761..78c252ed0ad 100644 --- a/tests/phpunit/includes/Storage/PageUpdaterTest.php +++ b/tests/phpunit/includes/Storage/PageUpdaterTest.php @@ -72,6 +72,8 @@ class PageUpdaterTest extends MediaWikiTestCase { */ public function testCreatePage() { $this->hideDeprecated( 'WikiPage::getRevision' ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doCreate status get 'revision'" ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doModify status get 'revision'" ); $user = $this->getTestUser()->getUser(); @@ -176,6 +178,8 @@ class PageUpdaterTest extends MediaWikiTestCase { */ public function testUpdatePage() { $this->hideDeprecated( 'WikiPage::getRevision' ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doCreate status get 'revision'" ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doModify status get 'revision'" ); $user = $this->getTestUser()->getUser(); diff --git a/tests/phpunit/includes/api/ApiPageSetTest.php b/tests/phpunit/includes/api/ApiPageSetTest.php index b1b8a425235..3f9bfd2b8cc 100644 --- a/tests/phpunit/includes/api/ApiPageSetTest.php +++ b/tests/phpunit/includes/api/ApiPageSetTest.php @@ -103,9 +103,9 @@ class ApiPageSetTest extends ApiTestCase { public function testSpecialRedirects() { $id1 = self::editPage( 'UTApiPageSet', 'UTApiPageSet in the default language' ) - ->value['revision']->getTitle()->getArticleID(); + ->value['revision-record']->getPageId(); $id2 = self::editPage( 'UTApiPageSet/de', 'UTApiPageSet in German' ) - ->value['revision']->getTitle()->getArticleID(); + ->value['revision-record']->getPageId(); $user = $this->getTestUser()->getUser(); $userName = $user->getName(); diff --git a/tests/phpunit/includes/page/WikiPageDbTest.php b/tests/phpunit/includes/page/WikiPageDbTest.php index 1762ff1f7e5..7fb06fdad7b 100644 --- a/tests/phpunit/includes/page/WikiPageDbTest.php +++ b/tests/phpunit/includes/page/WikiPageDbTest.php @@ -290,6 +290,8 @@ class WikiPageDbTest extends MediaWikiLangTestCase { $this->hideDeprecated( 'Revision::getContent' ); $this->hideDeprecated( 'WikiPage::getRevision' ); $this->hideDeprecated( 'WikiPage::prepareContentForEdit with a Revision object' ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doCreate status get 'revision'" ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doModify status get 'revision'" ); $this->setMwGlobals( 'wgPageCreationLog', true ); @@ -411,6 +413,9 @@ class WikiPageDbTest extends MediaWikiLangTestCase { * @covers WikiPage::doEditContent */ public function testDoEditContent_twice() { + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doCreate status exists 'revision'" ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doModify status exists 'revision'" ); + $title = Title::newFromText( __METHOD__ ); $page = WikiPage::factory( $title ); $content = ContentHandler::makeContent( '$1 van $2', $title ); @@ -1221,6 +1226,8 @@ more stuff public function testDoRollback() { $this->hideDeprecated( 'Revision::countByPageId' ); $this->hideDeprecated( 'Revision::getUserText' ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doCreate status get 'revision'" ); + $this->hideDeprecated( "MediaWiki\Storage\PageUpdater::doModify status get 'revision'" ); $admin = $this->getTestSysop()->getUser(); $user1 = $this->getTestUser()->getUser();