Replace uses of Revision constants

Bug: T257010
Change-Id: Id63123e8b8becd31756d5b68ca11edb238ec8a59
This commit is contained in:
DannyS712 2020-07-03 00:20:38 +00:00
parent a30af56472
commit 2f4b71fc6c
11 changed files with 57 additions and 43 deletions

View file

@ -1444,8 +1444,8 @@ class EditPage implements IEditObject {
/**
* Get the current content of the page. This is basically similar to
* WikiPage::getContent( Revision::RAW ) except that when the page doesn't exist an empty
* content object is returned instead of null.
* WikiPage::getContent( RevisionRecord::RAW ) except that when the page doesn't
* exist an empty content object is returned instead of null.
*
* @since 1.21
* @return Content

View file

@ -24,6 +24,7 @@
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\RevisionStore;
use Wikimedia\AtEase\AtEase;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
@ -2213,7 +2214,7 @@ class LocalFile extends File {
}
$store = MediaWikiServices::getInstance()->getRevisionStore();
$revision = $store->getRevisionByTitle( $this->title, 0, Revision::READ_NORMAL );
$revision = $store->getRevisionByTitle( $this->title, 0, RevisionStore::READ_NORMAL );
if ( !$revision ) {
return false;
}

View file

@ -791,9 +791,9 @@ class WikiPage implements Page, IDBAccessObject {
* Get the content of the current revision. No side-effects...
*
* @param int $audience One of:
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $wgUser
* Revision::RAW get the text regardless of permissions
* RevisionRecord::FOR_PUBLIC to be displayed to all users
* RevisionRecord::FOR_THIS_USER to be displayed to $wgUser
* RevisionRecord::RAW get the text regardless of permissions
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
* to the $audience parameter
* @return Content|null The content of the current revision
@ -831,9 +831,9 @@ class WikiPage implements Page, IDBAccessObject {
/**
* @param int $audience One of:
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
* RevisionRecord::FOR_PUBLIC to be displayed to all users
* RevisionRecord::FOR_THIS_USER to be displayed to the given user
* RevisionRecord::RAW get the text regardless of permissions
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
* @return int User ID for the user that made the last article revision
@ -859,9 +859,9 @@ class WikiPage implements Page, IDBAccessObject {
/**
* Get the User object of the user who created the page
* @param int $audience One of:
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
* RevisionRecord::FOR_PUBLIC to be displayed to all users
* RevisionRecord::FOR_THIS_USER to be displayed to the given user
* RevisionRecord::RAW get the text regardless of permissions
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
* @return User|null
@ -885,9 +885,9 @@ class WikiPage implements Page, IDBAccessObject {
/**
* @param int $audience One of:
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
* RevisionRecord::FOR_PUBLIC to be displayed to all users
* RevisionRecord::FOR_THIS_USER to be displayed to the given user
* RevisionRecord::RAW get the text regardless of permissions
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
* @return string Username of the user that made the last article revision
@ -912,9 +912,9 @@ class WikiPage implements Page, IDBAccessObject {
/**
* @param int $audience One of:
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to the given user
* Revision::RAW get the text regardless of permissions
* RevisionRecord::FOR_PUBLIC to be displayed to all users
* RevisionRecord::FOR_THIS_USER to be displayed to the given user
* RevisionRecord::RAW get the text regardless of permissions
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
* @return string|null Comment stored for the last article revision, or null if the specified

View file

@ -28,6 +28,7 @@
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\ScopedCallback;
@ -1658,7 +1659,7 @@ class ParserTestRunner {
$page->loadPageData( 'fromdbmaster' );
if ( $page->exists() ) {
$content = $page->getContent( Revision::RAW );
$content = $page->getContent( RevisionRecord::RAW );
// Only reject the title, if the content/content model is different.
// This makes it easier to create Template:(( or Template:)) in different extensions
if ( $newContent->equals( $content ) ) {

View file

@ -6,6 +6,7 @@ use MediaWiki\Logger\LegacySpi;
use MediaWiki\Logger\LogCapturingSpi;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestResult;
use Psr\Log\LoggerInterface;
@ -2380,12 +2381,12 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
* Revision-deletes a revision.
*
* @param RevisionRecord|int $rev Revision to delete
* @param array $value Keys are Revision::DELETED_* flags. Values are 1 to set the bit, 0 to
* clear, -1 to leave alone. (All other values also clear the bit.)
* @param array $value Keys are RevisionRecord::DELETED_* flags. Values are 1 to set the bit,
* 0 to clear, -1 to leave alone. (All other values also clear the bit.)
* @param string $comment Deletion comment
*/
protected function revisionDelete(
$rev, array $value = [ Revision::DELETED_TEXT => 1 ], $comment = ''
$rev, array $value = [ RevisionRecord::DELETED_TEXT => 1 ], $comment = ''
) {
if ( is_int( $rev ) ) {
$rev = MediaWikiServices::getInstance()

View file

@ -1,5 +1,7 @@
<?php
use MediaWiki\Revision\RevisionRecord;
/**
* @group API
* @group Database
@ -89,9 +91,9 @@ class ApiComparePagesTest extends ApiTestCase {
[ self::$repl['revB2'] ]
)->setVisibility( [
'value' => [
Revision::DELETED_TEXT => 1,
Revision::DELETED_USER => 1,
Revision::DELETED_COMMENT => 1,
RevisionRecord::DELETED_TEXT => 1,
RevisionRecord::DELETED_USER => 1,
RevisionRecord::DELETED_COMMENT => 1,
],
'comment' => 'Test for ApiComparePages',
] );
@ -103,9 +105,9 @@ class ApiComparePagesTest extends ApiTestCase {
[ self::$repl['revB3'] ]
)->setVisibility( [
'value' => [
Revision::DELETED_USER => 1,
Revision::DELETED_COMMENT => 1,
Revision::DELETED_RESTRICTED => 1,
RevisionRecord::DELETED_USER => 1,
RevisionRecord::DELETED_COMMENT => 1,
RevisionRecord::DELETED_RESTRICTED => 1,
],
'comment' => 'Test for ApiComparePages',
] );

View file

@ -1,6 +1,7 @@
<?php
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Revision\RevisionRecord;
/**
* Tests for MediaWiki api.php?action=edit.
@ -177,7 +178,7 @@ class ApiEditPageTest extends ApiTestCase {
] );
$this->assertSame( 'Success', $re['edit']['result'] );
$newtext = WikiPage::factory( Title::newFromText( $name ) )
->getContent( Revision::RAW )
->getContent( RevisionRecord::RAW )
->getText();
$this->assertSame( "==section 1==\nnew content 1\n\n==section 2==\ncontent2", $newtext );
@ -217,7 +218,7 @@ class ApiEditPageTest extends ApiTestCase {
$this->assertSame( 'Success', $re['edit']['result'] );
// Check the page text is correct
$text = WikiPage::factory( Title::newFromText( $name ) )
->getContent( Revision::RAW )
->getContent( RevisionRecord::RAW )
->getText();
$this->assertSame( "== header ==\n\ntest", $text );
@ -233,7 +234,7 @@ class ApiEditPageTest extends ApiTestCase {
$this->assertSame( 'Success', $re2['edit']['result'] );
$text = WikiPage::factory( Title::newFromText( $name ) )
->getContent( Revision::RAW )
->getContent( RevisionRecord::RAW )
->getText();
$this->assertSame( "== header ==\n\ntest\n\n== header ==\n\ntest", $text );
}
@ -731,7 +732,7 @@ class ApiEditPageTest extends ApiTestCase {
$list = RevisionDeleter::createList( 'revision',
RequestContext::getMain(), $titleObj, [ $revId1 ] );
$list->setVisibility( [
'value' => [ Revision::DELETED_TEXT => 1 ],
'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
'comment' => 'Bye-bye',
] );

View file

@ -20,6 +20,7 @@
* @file
*/
use MediaWiki\Revision\RevisionRecord;
use Psr\Container\ContainerInterface;
use Wikimedia\ObjectFactory;
@ -54,7 +55,10 @@ class ApiParseTest extends ApiTestCase {
$this->revisionDelete( self::$revIds['revdel'] );
$this->revisionDelete(
self::$revIds['suppressed'],
[ Revision::DELETED_TEXT => 1, Revision::DELETED_RESTRICTED => 1 ]
[
RevisionRecord::DELETED_TEXT => 1,
RevisionRecord::DELETED_RESTRICTED => 1
]
);
Title::clearCaches(); // Otherwise it has the wrong latest revision for some reason

View file

@ -62,7 +62,9 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase {
$page = WikiPage::factory( $title );
self::$pageRev = $page->getRevisionRecord();
self::$revUser = User::newFromIdentity( self::$pageRev->getUser( Revision::RAW ) );
self::$revUser = User::newFromIdentity(
self::$pageRev->getUser( RevisionRecord::RAW )
);
}
private function newChange( RevisionRecord $revision = null ) {

View file

@ -3,6 +3,7 @@
use MediaWiki\Edit\PreparedEdit;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Storage\RevisionSlotsUpdate;
use PHPUnit\Framework\MockObject\MockObject;
@ -642,17 +643,17 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
);
$this->assertNull(
$page->getContent( Revision::FOR_PUBLIC ),
$page->getContent( RevisionRecord::FOR_PUBLIC ),
"WikiPage::getContent should return null after the page was suppressed for general users"
);
$this->assertNull(
$page->getContent( Revision::FOR_THIS_USER, $this->getTestUser()->getUser() ),
$page->getContent( RevisionRecord::FOR_THIS_USER, $this->getTestUser()->getUser() ),
"WikiPage::getContent should return null after the page was suppressed for individual users"
);
$this->assertNull(
$page->getContent( Revision::FOR_THIS_USER, $user ),
$page->getContent( RevisionRecord::FOR_THIS_USER, $user ),
"WikiPage::getContent should return null after the page was suppressed even for a sysop"
);
}
@ -1948,7 +1949,7 @@ more stuff
);
$this->assertTrue( $result instanceof Revision );
$this->assertSame( $expectedComment, $result->getComment( Revision::RAW ) );
$this->assertSame( $expectedComment, $result->getComment( RevisionRecord::RAW ) );
}
/**

View file

@ -1,6 +1,7 @@
<?php
use MediaWiki\Permissions\PermissionManager;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\User\UserIdentityValue;
use PHPUnit\Framework\MockObject\MockObject;
use Wikimedia\Rdbms\IDatabase;
@ -1071,7 +1072,7 @@ class WatchedItemQueryServiceUnitTest extends MediaWikiIntegrationTestCase {
[ 'actormigration' => 'table' ],
[
'actormigration_conds',
'(rc_deleted & ' . Revision::DELETED_USER . ') != ' . Revision::DELETED_USER,
'(rc_deleted & ' . RevisionRecord::DELETED_USER . ') != ' . RevisionRecord::DELETED_USER,
'(rc_type != ' . RC_LOG . ') OR ((rc_deleted & ' . LogPage::DELETED_ACTION . ') != ' .
LogPage::DELETED_ACTION . ')'
],
@ -1083,8 +1084,8 @@ class WatchedItemQueryServiceUnitTest extends MediaWikiIntegrationTestCase {
[ 'actormigration' => 'table' ],
[
'actormigration_conds',
'(rc_deleted & ' . ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ) . ') != ' .
( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ),
'(rc_deleted & ' . ( RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED ) . ') != ' .
( RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED ),
'(rc_type != ' . RC_LOG . ') OR (' .
'(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
@ -1097,8 +1098,8 @@ class WatchedItemQueryServiceUnitTest extends MediaWikiIntegrationTestCase {
[ 'actormigration' => 'table' ],
[
'actormigration_conds',
'(rc_deleted & ' . ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ) . ') != ' .
( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ),
'(rc_deleted & ' . ( RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED ) . ') != ' .
( RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED ),
'(rc_type != ' . RC_LOG . ') OR (' .
'(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'