Add namespace to ContentModelChange
It adds MediaWiki\Content namespace to ContentModelChange Bug: T353458 Change-Id: Ia9fbff3b7d25a83be58fffbfc01274c9fcc7a482
This commit is contained in:
parent
d98eb89fde
commit
c586a7207c
7 changed files with 28 additions and 5 deletions
|
|
@ -347,6 +347,7 @@ because of Phabricator reports.
|
|||
been moved:
|
||||
- MediaWiki\Content:
|
||||
- CodeContentHandler
|
||||
- ContentModelChange
|
||||
- CssContent
|
||||
- CssContentHandler
|
||||
- FallbackContent
|
||||
|
|
|
|||
|
|
@ -1001,6 +1001,7 @@ $wgAutoloadLocalClasses = [
|
|||
'MediaWiki\\Config\\SiteConfiguration' => __DIR__ . '/includes/config/SiteConfiguration.php',
|
||||
'MediaWiki\\Content\\CodeContentHandler' => __DIR__ . '/includes/content/CodeContentHandler.php',
|
||||
'MediaWiki\\Content\\ContentHandlerFactory' => __DIR__ . '/includes/content/ContentHandlerFactory.php',
|
||||
'MediaWiki\\Content\\ContentModelChange' => __DIR__ . '/includes/content/ContentModelChange.php',
|
||||
'MediaWiki\\Content\\CssContent' => __DIR__ . '/includes/content/CssContent.php',
|
||||
'MediaWiki\\Content\\CssContentHandler' => __DIR__ . '/includes/content/CssContentHandler.php',
|
||||
'MediaWiki\\Content\\FallbackContent' => __DIR__ . '/includes/content/FallbackContent.php',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Content\IContentHandlerFactory;
|
||||
namespace MediaWiki\Content;
|
||||
|
||||
use ChangeTags;
|
||||
use Content;
|
||||
use ContentHandler;
|
||||
use LogFormatterFactory;
|
||||
use ManualLogEntry;
|
||||
use MediaWiki\Context\DerivativeContext;
|
||||
use MediaWiki\Context\IContextSource;
|
||||
use MediaWiki\Context\RequestContext;
|
||||
|
|
@ -15,6 +21,8 @@ use MediaWiki\Revision\RevisionLookup;
|
|||
use MediaWiki\Revision\SlotRecord;
|
||||
use MediaWiki\Status\Status;
|
||||
use MediaWiki\User\UserFactory;
|
||||
use MWException;
|
||||
use WikiPage;
|
||||
|
||||
/**
|
||||
* Backend logic for changing the content model of a page.
|
||||
|
|
@ -56,6 +64,7 @@ class ContentModelChange {
|
|||
|
||||
/**
|
||||
* @internal Create via the ContentModelChangeFactory service.
|
||||
*
|
||||
* @param IContentHandlerFactory $contentHandlerFactory
|
||||
* @param HookContainer $hookContainer
|
||||
* @param RevisionLookup $revLookup
|
||||
|
|
@ -109,6 +118,7 @@ class ContentModelChange {
|
|||
|
||||
/**
|
||||
* @param callable $authorizer ( string $action, PageIdentity $target, PermissionStatus $status )
|
||||
*
|
||||
* @return PermissionStatus
|
||||
*/
|
||||
private function authorizeInternal( callable $authorizer ): PermissionStatus {
|
||||
|
|
@ -121,6 +131,7 @@ class ContentModelChange {
|
|||
$authorizer( 'edit', $this->pageIdentity, $status );
|
||||
$authorizer( 'editcontentmodel', $titleWithNewContentModel, $status );
|
||||
$authorizer( 'edit', $titleWithNewContentModel, $status );
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
|
@ -177,12 +188,14 @@ class ContentModelChange {
|
|||
* Specify the tags the user wants to add, and check permissions
|
||||
*
|
||||
* @param string[] $tags
|
||||
*
|
||||
* @return Status
|
||||
*/
|
||||
public function setTags( $tags ) {
|
||||
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $tags, $this->performer );
|
||||
if ( $tagStatus->isOK() ) {
|
||||
$this->tags = $tags;
|
||||
|
||||
return Status::newGood();
|
||||
} else {
|
||||
return $tagStatus;
|
||||
|
|
@ -249,6 +262,7 @@ class ContentModelChange {
|
|||
$this->logAction = 'new';
|
||||
}
|
||||
$this->newContent = $newContent;
|
||||
|
||||
return Status::newGood();
|
||||
}
|
||||
|
||||
|
|
@ -260,6 +274,7 @@ class ContentModelChange {
|
|||
* @param IContextSource $context
|
||||
* @param string $comment
|
||||
* @param bool $bot Mark as a bot edit if the user can
|
||||
*
|
||||
* @return Status
|
||||
*/
|
||||
public function doContentModelChange(
|
||||
|
|
@ -310,12 +325,14 @@ class ContentModelChange {
|
|||
// TODO: extensions should really specify an error message
|
||||
$status->fatal( 'hookaborted' );
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
if ( !$status->isOK() ) {
|
||||
if ( !$status->getMessages() ) {
|
||||
$status->fatal( 'hookaborted' );
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
|
@ -350,3 +367,6 @@ class ContentModelChange {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/** @deprecated class alias since 1.43 */
|
||||
class_alias( ContentModelChange::class, 'ContentModelChange' );
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace MediaWiki\Page;
|
||||
|
||||
use ContentModelChange;
|
||||
use MediaWiki\Content\ContentModelChange;
|
||||
use MediaWiki\Permissions\Authority;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace MediaWiki\Page;
|
||||
|
||||
use ContentModelChange;
|
||||
use JobQueueGroup;
|
||||
use LogFormatterFactory;
|
||||
use MediaWiki\Cache\BacklinkCacheFactory;
|
||||
|
|
@ -29,6 +28,7 @@ use MediaWiki\Collation\CollationFactory;
|
|||
use MediaWiki\CommentStore\CommentStore;
|
||||
use MediaWiki\Config\Config;
|
||||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\Content\ContentModelChange;
|
||||
use MediaWiki\Content\IContentHandlerFactory;
|
||||
use MediaWiki\EditPage\SpamChecker;
|
||||
use MediaWiki\HookContainer\HookContainer;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Content\ContentModelChange;
|
||||
use MediaWiki\Context\RequestContext;
|
||||
use MediaWiki\Page\PageIdentity;
|
||||
use MediaWiki\Page\WikiPageFactory;
|
||||
|
|
@ -15,7 +16,7 @@ use MediaWiki\Title\Title;
|
|||
* TODO convert to a pure unit test
|
||||
*
|
||||
* @group Database
|
||||
* @covers \ContentModelChange
|
||||
* @covers \MediaWiki\Content\ContentModelChange
|
||||
*
|
||||
* @author DannyS712
|
||||
* @method ContentModelChange newServiceInstance(string $serviceClass, array $parameterOverrides)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace MediaWiki\Tests\Unit\Page;
|
||||
|
||||
use ContentModelChange;
|
||||
use MediaWiki\Config\HashConfig;
|
||||
use MediaWiki\Content\ContentModelChange;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Page\DeletePage;
|
||||
use MediaWiki\Page\MergeHistory;
|
||||
|
|
|
|||
Loading…
Reference in a new issue