Merge "PageUpdater: set DeprecatablePropertyArray to hard deprecate Revision"

This commit is contained in:
jenkins-bot 2020-07-01 00:11:55 +00:00 committed by Gerrit Code Review
commit fdad7c030d
7 changed files with 35 additions and 13 deletions

View file

@ -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.

View file

@ -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(

View file

@ -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

View file

@ -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
} ],
] );

View file

@ -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();

View file

@ -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();

View file

@ -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();