2012-05-25 19:50:48 +00:00
|
|
|
<?php
|
2012-07-19 00:11:26 +00:00
|
|
|
/**
|
2015-09-14 16:13:31 +00:00
|
|
|
* Parsoid/RESTBase+MediaWiki API wrapper.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
2021-08-09 10:43:53 +00:00
|
|
|
* @copyright 2011-2021 VisualEditor Team and others; see AUTHORS.txt
|
2018-03-28 19:47:04 +00:00
|
|
|
* @license MIT
|
2012-07-19 00:11:26 +00:00
|
|
|
*/
|
|
|
|
|
2022-03-13 01:38:23 +00:00
|
|
|
namespace MediaWiki\Extension\VisualEditor;
|
|
|
|
|
|
|
|
use ApiBase;
|
|
|
|
use ApiBlockInfoTrait;
|
|
|
|
use ApiMain;
|
|
|
|
use ApiResult;
|
|
|
|
use Article;
|
|
|
|
use ContentHandler;
|
|
|
|
use ExtensionRegistry;
|
2022-11-10 10:00:31 +00:00
|
|
|
use IBufferingStatsdDataFactory;
|
2024-06-10 20:35:51 +00:00
|
|
|
use MediaWiki\Config\Config;
|
2021-08-06 12:36:46 +00:00
|
|
|
use MediaWiki\Content\Transform\ContentTransformer;
|
2024-06-10 20:35:51 +00:00
|
|
|
use MediaWiki\Context\DerivativeContext;
|
|
|
|
use MediaWiki\Context\RequestContext;
|
2023-05-06 21:21:44 +00:00
|
|
|
use MediaWiki\EditPage\EditPage;
|
2023-04-20 21:55:48 +00:00
|
|
|
use MediaWiki\EditPage\IntroMessageBuilder;
|
|
|
|
use MediaWiki\EditPage\PreloadedContentBuilder;
|
|
|
|
use MediaWiki\EditPage\TextboxBuilder;
|
2023-08-20 00:07:00 +00:00
|
|
|
use MediaWiki\Language\RawMessage;
|
2019-10-01 22:17:36 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
2020-01-10 17:51:36 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2023-04-20 21:55:48 +00:00
|
|
|
use MediaWiki\Page\PageReference;
|
2022-04-27 18:05:32 +00:00
|
|
|
use MediaWiki\Page\WikiPageFactory;
|
2024-08-09 12:31:09 +00:00
|
|
|
use MediaWiki\Permissions\PermissionManager;
|
2023-08-19 23:40:59 +00:00
|
|
|
use MediaWiki\Request\DerivativeRequest;
|
2022-09-02 01:09:45 +00:00
|
|
|
use MediaWiki\Revision\RevisionLookup;
|
2023-08-15 18:39:10 +00:00
|
|
|
use MediaWiki\SpecialPage\SpecialPageFactory;
|
2023-08-19 04:21:24 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2023-11-29 12:41:16 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsLookup;
|
2023-04-27 22:23:16 +00:00
|
|
|
use MediaWiki\User\TempUser\TempUserCreator;
|
2024-06-10 20:35:51 +00:00
|
|
|
use MediaWiki\User\User;
|
2023-07-18 02:14:09 +00:00
|
|
|
use MediaWiki\User\UserFactory;
|
2024-02-20 10:27:15 +00:00
|
|
|
use MediaWiki\User\UserIdentity;
|
2021-08-09 10:43:53 +00:00
|
|
|
use MediaWiki\Watchlist\WatchlistManager;
|
2023-04-20 21:55:48 +00:00
|
|
|
use MessageLocalizer;
|
2023-11-03 16:05:08 +00:00
|
|
|
use Wikimedia\Assert\Assert;
|
2020-07-20 20:43:59 +00:00
|
|
|
use Wikimedia\ParamValidator\ParamValidator;
|
2022-03-13 01:38:23 +00:00
|
|
|
use WikitextContent;
|
2016-12-31 04:37:10 +00:00
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
class ApiVisualEditor extends ApiBase {
|
2019-05-08 20:01:36 +00:00
|
|
|
use ApiBlockInfoTrait;
|
2020-05-19 17:53:29 +00:00
|
|
|
use ApiParsoidTrait;
|
2019-05-08 20:01:36 +00:00
|
|
|
|
2023-04-24 19:10:30 +00:00
|
|
|
private RevisionLookup $revisionLookup;
|
2023-04-27 22:23:16 +00:00
|
|
|
private TempUserCreator $tempUserCreator;
|
2023-07-18 02:14:09 +00:00
|
|
|
private UserFactory $userFactory;
|
2023-04-24 19:10:30 +00:00
|
|
|
private UserOptionsLookup $userOptionsLookup;
|
|
|
|
private WatchlistManager $watchlistManager;
|
|
|
|
private ContentTransformer $contentTransformer;
|
|
|
|
private WikiPageFactory $wikiPageFactory;
|
2023-04-20 21:55:48 +00:00
|
|
|
private IntroMessageBuilder $introMessageBuilder;
|
|
|
|
private PreloadedContentBuilder $preloadedContentBuilder;
|
2023-08-15 18:39:10 +00:00
|
|
|
private SpecialPageFactory $specialPageFactory;
|
2023-04-24 19:10:30 +00:00
|
|
|
private VisualEditorParsoidClientFactory $parsoidClientFactory;
|
2022-09-02 01:09:45 +00:00
|
|
|
|
2021-08-09 10:43:53 +00:00
|
|
|
public function __construct(
|
|
|
|
ApiMain $main,
|
2023-04-24 19:10:30 +00:00
|
|
|
string $name,
|
2022-09-02 01:09:45 +00:00
|
|
|
RevisionLookup $revisionLookup,
|
2023-04-27 22:23:16 +00:00
|
|
|
TempUserCreator $tempUserCreator,
|
2023-07-18 02:14:09 +00:00
|
|
|
UserFactory $userFactory,
|
2021-08-09 10:43:53 +00:00
|
|
|
UserOptionsLookup $userOptionsLookup,
|
2021-08-06 12:36:46 +00:00
|
|
|
WatchlistManager $watchlistManager,
|
2021-12-26 13:23:42 +00:00
|
|
|
ContentTransformer $contentTransformer,
|
2022-11-10 10:00:31 +00:00
|
|
|
IBufferingStatsdDataFactory $statsdDataFactory,
|
2022-04-27 18:05:32 +00:00
|
|
|
WikiPageFactory $wikiPageFactory,
|
2023-04-20 21:55:48 +00:00
|
|
|
IntroMessageBuilder $introMessageBuilder,
|
|
|
|
PreloadedContentBuilder $preloadedContentBuilder,
|
2023-08-15 18:39:10 +00:00
|
|
|
SpecialPageFactory $specialPageFactory,
|
2022-09-05 10:36:16 +00:00
|
|
|
VisualEditorParsoidClientFactory $parsoidClientFactory
|
2021-08-09 10:43:53 +00:00
|
|
|
) {
|
2014-08-13 08:15:42 +00:00
|
|
|
parent::__construct( $main, $name );
|
2020-03-16 23:30:26 +00:00
|
|
|
$this->setLogger( LoggerFactory::getInstance( 'VisualEditor' ) );
|
2022-11-10 10:00:31 +00:00
|
|
|
$this->setStats( $statsdDataFactory );
|
2022-09-02 01:09:45 +00:00
|
|
|
$this->revisionLookup = $revisionLookup;
|
2023-04-27 22:23:16 +00:00
|
|
|
$this->tempUserCreator = $tempUserCreator;
|
2023-07-18 02:14:09 +00:00
|
|
|
$this->userFactory = $userFactory;
|
2021-08-09 10:43:53 +00:00
|
|
|
$this->userOptionsLookup = $userOptionsLookup;
|
|
|
|
$this->watchlistManager = $watchlistManager;
|
2021-08-06 12:36:46 +00:00
|
|
|
$this->contentTransformer = $contentTransformer;
|
2022-04-27 18:05:32 +00:00
|
|
|
$this->wikiPageFactory = $wikiPageFactory;
|
2023-04-20 21:55:48 +00:00
|
|
|
$this->introMessageBuilder = $introMessageBuilder;
|
|
|
|
$this->preloadedContentBuilder = $preloadedContentBuilder;
|
2023-08-15 18:39:10 +00:00
|
|
|
$this->specialPageFactory = $specialPageFactory;
|
2022-09-05 10:36:16 +00:00
|
|
|
$this->parsoidClientFactory = $parsoidClientFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected function getParsoidClient(): ParsoidClient {
|
|
|
|
return $this->parsoidClientFactory->createParsoidClient(
|
|
|
|
$this->getRequest()->getHeader( 'Cookie' )
|
|
|
|
);
|
2014-04-18 20:17:02 +00:00
|
|
|
}
|
|
|
|
|
2023-08-08 16:22:27 +00:00
|
|
|
/**
|
|
|
|
* @see EditPage::getUserForPermissions
|
|
|
|
*/
|
2024-02-20 10:27:15 +00:00
|
|
|
private function getUserForPermissions(): User {
|
2023-08-08 16:22:27 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
if ( $this->tempUserCreator->shouldAutoCreate( $user, 'edit' ) ) {
|
|
|
|
return $this->userFactory->newUnsavedTempUser(
|
|
|
|
$this->tempUserCreator->getStashedName( $this->getRequest()->getSession() )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
|
2023-07-18 02:14:09 +00:00
|
|
|
/**
|
|
|
|
* @see ApiParse::getUserForPreview
|
|
|
|
*/
|
2024-02-20 10:27:15 +00:00
|
|
|
private function getUserForPreview(): UserIdentity {
|
2023-07-18 02:14:09 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
if ( $this->tempUserCreator->shouldAutoCreate( $user, 'edit' ) ) {
|
|
|
|
return $this->userFactory->newUnsavedTempUser(
|
|
|
|
$this->tempUserCreator->getStashedName( $this->getRequest()->getSession() )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* Run wikitext through the parser's Pre-Save-Transform
|
|
|
|
*
|
2018-06-26 15:35:09 +00:00
|
|
|
* @param Title $title The title of the page to use as the parsing context
|
2018-03-28 19:47:04 +00:00
|
|
|
* @param string $wikitext The wikitext to transform
|
|
|
|
* @return string The transformed wikitext
|
|
|
|
*/
|
2018-06-26 15:35:09 +00:00
|
|
|
protected function pstWikitext( Title $title, $wikitext ) {
|
2021-08-06 12:36:46 +00:00
|
|
|
$content = ContentHandler::makeContent( $wikitext, $title, CONTENT_MODEL_WIKITEXT );
|
|
|
|
return $this->contentTransformer->preSaveTransform(
|
|
|
|
$content,
|
|
|
|
$title,
|
2023-07-18 02:14:09 +00:00
|
|
|
$this->getUserForPreview(),
|
2022-04-27 18:05:32 +00:00
|
|
|
$this->wikiPageFactory->newFromTitle( $title )->makeParserOptions( $this->getContext() )
|
2021-08-06 12:36:46 +00:00
|
|
|
)
|
|
|
|
->serialize( 'text/x-wiki' );
|
2014-10-22 22:47:21 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
2020-01-26 10:36:43 +00:00
|
|
|
* @suppress PhanPossiblyUndeclaredVariable False positives
|
2018-03-28 19:47:04 +00:00
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
public function execute() {
|
2012-07-21 17:37:20 +00:00
|
|
|
$user = $this->getUser();
|
2012-05-25 19:50:48 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2020-01-30 00:54:42 +00:00
|
|
|
$permissionManager = $this->getPermissionManager();
|
2014-03-21 00:44:30 +00:00
|
|
|
|
2015-03-26 19:32:01 +00:00
|
|
|
$title = Title::newFromText( $params['page'] );
|
2023-08-15 18:39:10 +00:00
|
|
|
if ( $title && $title->isSpecialPage() ) {
|
2016-10-25 20:44:26 +00:00
|
|
|
// Convert Special:CollabPad/MyPage to MyPage so we can parsefragment properly
|
2023-08-15 18:39:10 +00:00
|
|
|
[ $special, $subPage ] = $this->specialPageFactory->resolveAlias( $title->getDBkey() );
|
|
|
|
if ( $special === 'CollabPad' ) {
|
|
|
|
$title = Title::newFromText( $subPage );
|
|
|
|
}
|
2016-10-25 20:44:26 +00:00
|
|
|
}
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( !$title ) {
|
2016-11-03 19:16:57 +00:00
|
|
|
$this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['page'] ) ] );
|
2012-11-14 18:33:57 +00:00
|
|
|
}
|
2021-04-14 14:11:18 +00:00
|
|
|
if ( !$title->canExist() ) {
|
|
|
|
$this->dieWithError( 'apierror-pagecannotexist' );
|
|
|
|
}
|
2015-04-02 00:41:59 +00:00
|
|
|
|
2015-03-26 19:32:01 +00:00
|
|
|
wfDebugLog( 'visualeditor', "called on '$title' with paction: '{$params['paction']}'" );
|
2013-05-15 21:17:06 +00:00
|
|
|
switch ( $params['paction'] ) {
|
|
|
|
case 'parse':
|
2016-05-26 12:08:26 +00:00
|
|
|
case 'wikitext':
|
2015-03-13 22:15:17 +00:00
|
|
|
case 'metadata':
|
2022-05-10 22:01:50 +00:00
|
|
|
// Dirty hack to provide the correct context for FlaggedRevs when it generates edit notices
|
|
|
|
// and save dialog checkboxes. (T307852)
|
|
|
|
// FIXME Don't write to globals! Eww.
|
|
|
|
RequestContext::getMain()->setTitle( $title );
|
|
|
|
|
2017-10-26 16:32:12 +00:00
|
|
|
$preloaded = false;
|
2019-05-14 15:07:22 +00:00
|
|
|
$restbaseHeaders = null;
|
2017-10-26 16:32:12 +00:00
|
|
|
|
2020-12-16 23:15:57 +00:00
|
|
|
$section = $params['section'] ?? null;
|
|
|
|
|
2015-03-13 22:15:17 +00:00
|
|
|
// Get information about current revision
|
|
|
|
if ( $title->exists() ) {
|
2022-09-02 01:09:45 +00:00
|
|
|
$latestRevision = $this->revisionLookup->getRevisionByTitle( $title );
|
|
|
|
if ( !$latestRevision ) {
|
|
|
|
$this->dieWithError(
|
|
|
|
[ 'apierror-missingrev-title', wfEscapeWikiText( $title->getPrefixedText() ) ],
|
|
|
|
'nosuchrevid'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( isset( $params['oldid'] ) ) {
|
|
|
|
$revision = $this->revisionLookup->getRevisionById( $params['oldid'] );
|
|
|
|
if ( !$revision ) {
|
|
|
|
$this->dieWithError( [ 'apierror-nosuchrevid', $params['oldid'] ] );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$revision = $latestRevision;
|
|
|
|
}
|
2015-03-13 22:15:17 +00:00
|
|
|
|
|
|
|
$baseTimestamp = $latestRevision->getTimestamp();
|
2020-06-10 15:03:26 +00:00
|
|
|
$oldid = $revision->getId();
|
2015-03-13 22:15:17 +00:00
|
|
|
|
2015-06-13 04:54:23 +00:00
|
|
|
// If requested, request HTML from Parsoid/RESTBase
|
2015-03-13 22:15:17 +00:00
|
|
|
if ( $params['paction'] === 'parse' ) {
|
2019-04-05 13:51:14 +00:00
|
|
|
$wikitext = $params['wikitext'] ?? null;
|
|
|
|
if ( $wikitext !== null ) {
|
|
|
|
$stash = $params['stash'];
|
|
|
|
if ( $params['pst'] ) {
|
|
|
|
$wikitext = $this->pstWikitext( $title, $wikitext );
|
|
|
|
}
|
|
|
|
if ( $section !== null ) {
|
|
|
|
$sectionContent = new WikitextContent( $wikitext );
|
2022-04-27 18:05:32 +00:00
|
|
|
$page = $this->wikiPageFactory->newFromTitle( $title );
|
2019-05-31 13:46:11 +00:00
|
|
|
$newSectionContent = $page->replaceSectionAtRev(
|
2019-04-05 13:51:14 +00:00
|
|
|
$section, $sectionContent, '', $oldid
|
2019-05-31 13:46:11 +00:00
|
|
|
);
|
|
|
|
'@phan-var WikitextContent $newSectionContent';
|
|
|
|
$wikitext = $newSectionContent->getText();
|
2019-04-05 13:51:14 +00:00
|
|
|
}
|
2020-07-22 13:38:33 +00:00
|
|
|
$response = $this->transformWikitext(
|
2019-04-05 13:51:14 +00:00
|
|
|
$title, $wikitext, false, $oldid, $stash
|
|
|
|
);
|
|
|
|
} else {
|
2020-06-10 15:03:26 +00:00
|
|
|
$response = $this->requestRestbasePageHtml( $revision );
|
2019-04-05 13:51:14 +00:00
|
|
|
}
|
2019-10-14 20:11:36 +00:00
|
|
|
$content = $response['body'];
|
|
|
|
$restbaseHeaders = $response['headers'];
|
2016-05-26 12:08:26 +00:00
|
|
|
} elseif ( $params['paction'] === 'wikitext' ) {
|
|
|
|
$apiParams = [
|
|
|
|
'action' => 'query',
|
2016-11-23 00:47:42 +00:00
|
|
|
'revids' => $oldid,
|
2016-05-26 12:08:26 +00:00
|
|
|
'prop' => 'revisions',
|
2016-11-23 00:47:42 +00:00
|
|
|
'rvprop' => 'content|ids'
|
2016-05-26 12:08:26 +00:00
|
|
|
];
|
2016-09-06 19:16:55 +00:00
|
|
|
|
2020-12-16 23:15:57 +00:00
|
|
|
$apiParams['rvsection'] = $section;
|
|
|
|
|
2021-04-28 23:58:28 +00:00
|
|
|
$context = new DerivativeContext( $this->getContext() );
|
|
|
|
$context->setRequest(
|
2020-12-16 23:15:57 +00:00
|
|
|
new DerivativeRequest(
|
2021-04-28 23:58:28 +00:00
|
|
|
$context->getRequest(),
|
2020-12-16 23:15:57 +00:00
|
|
|
$apiParams,
|
2021-04-28 23:58:28 +00:00
|
|
|
/* was posted? */ true
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$api = new ApiMain(
|
|
|
|
$context,
|
2020-12-16 23:15:57 +00:00
|
|
|
/* enable write? */ true
|
|
|
|
);
|
|
|
|
$api->execute();
|
|
|
|
$result = $api->getResult()->getResultData();
|
|
|
|
$pid = $title->getArticleID();
|
|
|
|
$content = false;
|
|
|
|
if ( isset( $result['query']['pages'][$pid]['revisions'] ) ) {
|
|
|
|
foreach ( $result['query']['pages'][$pid]['revisions'] as $revArr ) {
|
|
|
|
// Check 'revisions' is an array (T193718)
|
|
|
|
if ( is_array( $revArr ) && $revArr['revid'] === $oldid ) {
|
|
|
|
$content = $revArr['content'];
|
2016-11-23 00:47:42 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-16 23:15:57 +00:00
|
|
|
}
|
2015-03-13 22:15:17 +00:00
|
|
|
}
|
2023-04-20 21:55:48 +00:00
|
|
|
} else {
|
|
|
|
$revision = null;
|
2020-12-16 23:15:57 +00:00
|
|
|
}
|
|
|
|
|
2023-04-20 21:55:48 +00:00
|
|
|
// Use $title as the context page in every processed message (T300184)
|
|
|
|
$localizerWithTitle = new class( $this, $title ) implements MessageLocalizer {
|
|
|
|
private MessageLocalizer $base;
|
|
|
|
private PageReference $page;
|
|
|
|
|
|
|
|
public function __construct( MessageLocalizer $base, PageReference $page ) {
|
|
|
|
$this->base = $base;
|
|
|
|
$this->page = $page;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function msg( $key, ...$params ) {
|
|
|
|
return $this->base->msg( $key, ...$params )->page( $this->page );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-16 23:15:57 +00:00
|
|
|
if ( !$title->exists() || $section === 'new' ) {
|
2020-06-29 15:23:09 +00:00
|
|
|
if ( isset( $params['wikitext'] ) ) {
|
|
|
|
$content = $params['wikitext'];
|
|
|
|
if ( $params['pst'] ) {
|
|
|
|
$content = $this->pstWikitext( $title, $content );
|
|
|
|
}
|
|
|
|
} else {
|
2023-04-20 21:55:48 +00:00
|
|
|
$contentObj = $this->preloadedContentBuilder->getPreloadedContent(
|
|
|
|
$title->toPageIdentity(),
|
|
|
|
$user,
|
|
|
|
$params['preload'],
|
|
|
|
$params['preloadparams'] ?? [],
|
|
|
|
$section
|
|
|
|
);
|
|
|
|
$dfltContent = $section === 'new' ? null :
|
|
|
|
$this->preloadedContentBuilder->getDefaultContent( $title->toPageIdentity() );
|
|
|
|
$preloaded = $dfltContent ? !$contentObj->equals( $dfltContent ) : !$contentObj->isEmpty();
|
|
|
|
$content = $contentObj->serialize();
|
2017-09-14 20:08:09 +00:00
|
|
|
}
|
2020-06-29 15:23:09 +00:00
|
|
|
|
2019-10-23 20:24:52 +00:00
|
|
|
if ( $content !== '' && $params['paction'] !== 'wikitext' ) {
|
2020-07-22 13:38:33 +00:00
|
|
|
$response = $this->transformWikitext( $title, $content, false, null, true );
|
2019-10-23 20:24:52 +00:00
|
|
|
$content = $response['body'];
|
|
|
|
$restbaseHeaders = $response['headers'];
|
|
|
|
}
|
2015-03-13 22:15:17 +00:00
|
|
|
$baseTimestamp = wfTimestampNow();
|
|
|
|
$oldid = 0;
|
2013-05-15 21:17:06 +00:00
|
|
|
}
|
2014-03-26 21:33:19 +00:00
|
|
|
|
2014-04-30 19:28:29 +00:00
|
|
|
// Look at protection status to set up notices + surface class(es)
|
2023-04-20 21:55:48 +00:00
|
|
|
$builder = new TextboxBuilder();
|
|
|
|
$protectedClasses = $builder->getTextboxProtectionCSSClasses( $title );
|
2014-03-26 20:39:45 +00:00
|
|
|
|
2024-08-09 12:31:09 +00:00
|
|
|
// Simplified EditPage::getEditPermissionStatus()
|
2023-04-20 21:55:48 +00:00
|
|
|
// TODO: Use API
|
|
|
|
// action=query&prop=info&intestactions=edit&intestactionsdetail=full&errorformat=html&errorsuselocal=1
|
2024-08-09 12:31:09 +00:00
|
|
|
$status = $permissionManager->getPermissionStatus(
|
|
|
|
'edit', $this->getUserForPermissions(), $title, PermissionManager::RIGOR_FULL );
|
|
|
|
if ( !$status->isGood() ) {
|
ApiVisualEditor: Refactor edit notice code
* Query permission errors for 'edit' and 'create' in the same way,
and consistently with how MediaWiki core EditPage does it.
* Prefer using Title::getUserPermissionsErrors() instead of custom
code for user blocks. The result is the same, except for an extra
line like "You do not have permission to edit this page, for the
following reason:".
Note that this loses the 'type' => 'block' property on each notice,
which was previously used to track when a block notice was shown.
This was however removed in 96de1353d3abec99a2922416856c120c8ed98912,
and could probably be re-implemented by using the root 'blockinfo'
property anyway.
* When Title::getUserPermissionsErrors() returns multiple messages
(for example, you're blocked *and* the page is protected),
display them all in a list instead of only the first one, using
OutputPage::formatPermissionsErrorMessage().
That method returns wikitext, which we have to parse ourselves. This
is a bit silly, but I found this approach in SpecialChangeContentModel
in MediaWiki core, so it should be fine.
Change-Id: Ifaf95d8aab836e45665b1fbdf98dd1980a867d8c
2020-01-17 00:15:45 +00:00
|
|
|
// Show generic permission errors, including page protection, user blocks, etc.
|
2024-08-09 12:31:09 +00:00
|
|
|
$notice = $this->getOutput()->formatPermissionStatus( $status, 'edit' );
|
ApiVisualEditor: Refactor edit notice code
* Query permission errors for 'edit' and 'create' in the same way,
and consistently with how MediaWiki core EditPage does it.
* Prefer using Title::getUserPermissionsErrors() instead of custom
code for user blocks. The result is the same, except for an extra
line like "You do not have permission to edit this page, for the
following reason:".
Note that this loses the 'type' => 'block' property on each notice,
which was previously used to track when a block notice was shown.
This was however removed in 96de1353d3abec99a2922416856c120c8ed98912,
and could probably be re-implemented by using the root 'blockinfo'
property anyway.
* When Title::getUserPermissionsErrors() returns multiple messages
(for example, you're blocked *and* the page is protected),
display them all in a list instead of only the first one, using
OutputPage::formatPermissionsErrorMessage().
That method returns wikitext, which we have to parse ourselves. This
is a bit silly, but I found this approach in SpecialChangeContentModel
in MediaWiki core, so it should be fine.
Change-Id: Ifaf95d8aab836e45665b1fbdf98dd1980a867d8c
2020-01-17 00:15:45 +00:00
|
|
|
// That method returns wikitext (eww), hack to get it parsed:
|
2022-07-20 04:31:44 +00:00
|
|
|
$notice = ( new RawMessage( '$1', [ $notice ] ) )->page( $title )->parseAsBlock();
|
2021-01-15 22:45:50 +00:00
|
|
|
// Invent a message key 'permissions-error' to store in $notices
|
2023-04-20 21:55:48 +00:00
|
|
|
// (This probably shouldn't use the notices system…)
|
|
|
|
$notices = [ 'permissions-error' => $notice ];
|
|
|
|
} else {
|
|
|
|
$notices = $this->introMessageBuilder->getIntroMessages(
|
|
|
|
IntroMessageBuilder::LESS_FRAMES,
|
2023-05-29 01:36:21 +00:00
|
|
|
[
|
|
|
|
// This message was not shown by VisualEditor before it was switched to use
|
|
|
|
// IntroMessageBuilder, and it may be unexpected to display it now, so skip it.
|
|
|
|
'editpage-head-copy-warn',
|
|
|
|
// This message was not shown by VisualEditor previously, and on many Wikipedias it's
|
|
|
|
// technically non-empty but hidden with CSS, and not a real edit notice (T337633).
|
|
|
|
'editnotice-notext',
|
|
|
|
],
|
2023-04-20 21:55:48 +00:00
|
|
|
$localizerWithTitle,
|
|
|
|
$title->toPageIdentity(),
|
|
|
|
$revision,
|
|
|
|
$user,
|
|
|
|
$params['editintro'],
|
|
|
|
null,
|
2023-09-13 11:09:42 +00:00
|
|
|
false,
|
|
|
|
$section
|
2023-04-20 21:55:48 +00:00
|
|
|
);
|
ApiVisualEditor: Refactor edit notice code
* Query permission errors for 'edit' and 'create' in the same way,
and consistently with how MediaWiki core EditPage does it.
* Prefer using Title::getUserPermissionsErrors() instead of custom
code for user blocks. The result is the same, except for an extra
line like "You do not have permission to edit this page, for the
following reason:".
Note that this loses the 'type' => 'block' property on each notice,
which was previously used to track when a block notice was shown.
This was however removed in 96de1353d3abec99a2922416856c120c8ed98912,
and could probably be re-implemented by using the root 'blockinfo'
property anyway.
* When Title::getUserPermissionsErrors() returns multiple messages
(for example, you're blocked *and* the page is protected),
display them all in a list instead of only the first one, using
OutputPage::formatPermissionsErrorMessage().
That method returns wikitext, which we have to parse ourselves. This
is a bit silly, but I found this approach in SpecialChangeContentModel
in MediaWiki core, so it should be fine.
Change-Id: Ifaf95d8aab836e45665b1fbdf98dd1980a867d8c
2020-01-17 00:15:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Will be false e.g. if user is blocked or page is protected
|
2024-08-09 12:31:09 +00:00
|
|
|
$canEdit = $status->isGood();
|
ApiVisualEditor: Refactor edit notice code
* Query permission errors for 'edit' and 'create' in the same way,
and consistently with how MediaWiki core EditPage does it.
* Prefer using Title::getUserPermissionsErrors() instead of custom
code for user blocks. The result is the same, except for an extra
line like "You do not have permission to edit this page, for the
following reason:".
Note that this loses the 'type' => 'block' property on each notice,
which was previously used to track when a block notice was shown.
This was however removed in 96de1353d3abec99a2922416856c120c8ed98912,
and could probably be re-implemented by using the root 'blockinfo'
property anyway.
* When Title::getUserPermissionsErrors() returns multiple messages
(for example, you're blocked *and* the page is protected),
display them all in a list instead of only the first one, using
OutputPage::formatPermissionsErrorMessage().
That method returns wikitext, which we have to parse ourselves. This
is a bit silly, but I found this approach in SpecialChangeContentModel
in MediaWiki core, so it should be fine.
Change-Id: Ifaf95d8aab836e45665b1fbdf98dd1980a867d8c
2020-01-17 00:15:45 +00:00
|
|
|
|
2019-04-30 17:02:58 +00:00
|
|
|
$blockinfo = null;
|
2015-03-13 22:15:17 +00:00
|
|
|
// Blocked user notice
|
2022-11-14 12:03:27 +00:00
|
|
|
if ( $permissionManager->isBlockedFrom( $user, $title, true ) ) {
|
2019-04-30 17:02:58 +00:00
|
|
|
$block = $user->getBlock();
|
2023-04-20 21:55:48 +00:00
|
|
|
if ( $block ) {
|
2024-08-09 12:31:09 +00:00
|
|
|
// Already added to $notices via #getPermissionStatus above.
|
2023-04-20 21:55:48 +00:00
|
|
|
// Add block info for MobileFrontend:
|
|
|
|
$blockinfo = $this->getBlockDetails( $block );
|
|
|
|
}
|
2014-04-22 00:22:48 +00:00
|
|
|
}
|
|
|
|
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
// HACK: Build a fake EditPage so we can get checkboxes from it
|
2017-05-04 22:27:27 +00:00
|
|
|
// Deliberately omitting ,0 so oldid comes from request
|
|
|
|
$article = new Article( $title );
|
2016-12-18 19:04:20 +00:00
|
|
|
$editPage = new EditPage( $article );
|
2013-08-02 18:37:30 +00:00
|
|
|
$req = $this->getRequest();
|
2016-12-18 19:04:20 +00:00
|
|
|
$req->setVal( 'format', $editPage->contentFormat );
|
2017-05-04 22:27:27 +00:00
|
|
|
// By reference for some reason (T54466)
|
|
|
|
$editPage->importFormData( $req );
|
2016-04-03 12:55:20 +00:00
|
|
|
$states = [
|
2021-08-09 10:43:53 +00:00
|
|
|
'minor' => $this->userOptionsLookup->getOption( $user, 'minordefault' ) && $title->exists(),
|
|
|
|
'watch' => $this->userOptionsLookup->getOption( $user, 'watchdefault' ) ||
|
|
|
|
( $this->userOptionsLookup->getOption( $user, 'watchcreations' ) && !$title->exists() ) ||
|
|
|
|
$this->watchlistManager->isWatched( $user, $title ),
|
2016-04-03 12:55:20 +00:00
|
|
|
];
|
2017-08-31 15:18:45 +00:00
|
|
|
$checkboxesDef = $editPage->getCheckboxesDefinition( $states );
|
2017-09-19 19:14:25 +00:00
|
|
|
$checkboxesMessagesList = [];
|
2021-06-03 13:54:40 +00:00
|
|
|
foreach ( $checkboxesDef as &$options ) {
|
2017-08-31 15:18:45 +00:00
|
|
|
if ( isset( $options['tooltip'] ) ) {
|
2017-09-19 19:14:25 +00:00
|
|
|
$checkboxesMessagesList[] = "accesskey-{$options['tooltip']}";
|
|
|
|
$checkboxesMessagesList[] = "tooltip-{$options['tooltip']}";
|
2017-08-31 15:18:45 +00:00
|
|
|
}
|
|
|
|
if ( isset( $options['title-message'] ) ) {
|
2017-09-19 19:14:25 +00:00
|
|
|
$checkboxesMessagesList[] = $options['title-message'];
|
|
|
|
if ( !is_string( $options['title-message'] ) ) {
|
|
|
|
// Extract only the key. Any parameters are included in the fake message definition
|
|
|
|
// passed via $checkboxesMessages. (This changes $checkboxesDef by reference.)
|
|
|
|
$options['title-message'] = $this->msg( $options['title-message'] )->getKey();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$checkboxesMessagesList[] = $options['label-message'];
|
|
|
|
if ( !is_string( $options['label-message'] ) ) {
|
|
|
|
// Extract only the key. Any parameters are included in the fake message definition
|
|
|
|
// passed via $checkboxesMessages. (This changes $checkboxesDef by reference.)
|
|
|
|
$options['label-message'] = $this->msg( $options['label-message'] )->getKey();
|
2017-08-31 15:18:45 +00:00
|
|
|
}
|
2017-09-19 19:14:25 +00:00
|
|
|
}
|
|
|
|
$checkboxesMessages = [];
|
|
|
|
foreach ( $checkboxesMessagesList as $messageSpecifier ) {
|
|
|
|
// $messageSpecifier may be a string or a Message object
|
|
|
|
$message = $this->msg( $messageSpecifier );
|
|
|
|
$checkboxesMessages[ $message->getKey() ] = $message->plain();
|
2017-08-31 15:18:45 +00:00
|
|
|
}
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
|
2017-08-31 15:18:45 +00:00
|
|
|
foreach ( $checkboxesDef as &$value ) {
|
|
|
|
// Don't convert the boolean to empty string with formatversion=1
|
|
|
|
$value[ApiResult::META_BC_BOOLS] = [ 'default' ];
|
|
|
|
}
|
2020-10-17 15:31:27 +00:00
|
|
|
|
2022-01-24 13:06:19 +00:00
|
|
|
$copyrightWarning = EditPage::getCopyrightWarning(
|
|
|
|
$title,
|
|
|
|
'parse',
|
|
|
|
$this
|
|
|
|
);
|
|
|
|
|
2023-04-27 22:23:16 +00:00
|
|
|
// Copied from EditPage::maybeActivateTempUserCreate
|
|
|
|
// Used by code in MobileFrontend and DiscussionTools.
|
|
|
|
// TODO Make them use API
|
|
|
|
// action=query&prop=info&intestactions=edit&intestactionsautocreate=1
|
|
|
|
$wouldautocreate =
|
|
|
|
!$user->isRegistered()
|
|
|
|
&& $this->tempUserCreator->isAutoCreateAction( 'edit' )
|
|
|
|
&& $permissionManager->userHasRight( $user, 'createaccount' );
|
|
|
|
|
2016-02-17 16:18:02 +00:00
|
|
|
$result = [
|
2015-03-13 22:15:17 +00:00
|
|
|
'result' => 'success',
|
|
|
|
'notices' => $notices,
|
2022-01-24 13:06:19 +00:00
|
|
|
'copyrightWarning' => $copyrightWarning,
|
2017-08-31 15:18:45 +00:00
|
|
|
'checkboxesDef' => $checkboxesDef,
|
|
|
|
'checkboxesMessages' => $checkboxesMessages,
|
2015-03-13 22:15:17 +00:00
|
|
|
'protectedClasses' => implode( ' ', $protectedClasses ),
|
|
|
|
'basetimestamp' => $baseTimestamp,
|
|
|
|
'starttimestamp' => wfTimestampNow(),
|
|
|
|
'oldid' => $oldid,
|
2019-04-30 17:02:58 +00:00
|
|
|
'blockinfo' => $blockinfo,
|
2023-04-27 22:23:16 +00:00
|
|
|
'wouldautocreate' => $wouldautocreate,
|
2019-05-18 15:09:13 +00:00
|
|
|
'canEdit' => $canEdit,
|
2016-02-17 16:18:02 +00:00
|
|
|
];
|
2019-12-18 07:22:25 +00:00
|
|
|
if ( isset( $restbaseHeaders['etag'] ) ) {
|
2019-04-05 13:51:14 +00:00
|
|
|
$result['etag'] = $restbaseHeaders['etag'];
|
|
|
|
}
|
2019-10-14 19:49:02 +00:00
|
|
|
if ( isset( $params['badetag'] ) ) {
|
|
|
|
$badetag = $params['badetag'];
|
|
|
|
$goodetag = $result['etag'] ?? '';
|
2020-03-16 23:30:26 +00:00
|
|
|
$this->getLogger()->info(
|
2019-10-21 14:38:23 +00:00
|
|
|
__METHOD__ . ": Client reported bad ETag: {badetag}, expected: {goodetag}",
|
|
|
|
[
|
|
|
|
'badetag' => $badetag,
|
|
|
|
'goodetag' => $goodetag,
|
|
|
|
]
|
2019-10-14 19:49:02 +00:00
|
|
|
);
|
|
|
|
}
|
2020-10-25 16:02:35 +00:00
|
|
|
|
|
|
|
if ( isset( $content ) ) {
|
2023-11-03 16:05:08 +00:00
|
|
|
Assert::postcondition( is_string( $content ), 'Content expected' );
|
2015-03-13 22:15:17 +00:00
|
|
|
$result['content'] = $content;
|
2023-04-20 21:55:48 +00:00
|
|
|
$result['preloaded'] = $preloaded;
|
2013-05-15 21:17:06 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-12-04 15:30:21 +00:00
|
|
|
|
2019-02-22 18:50:46 +00:00
|
|
|
case 'templatesused':
|
|
|
|
// HACK: Build a fake EditPage so we can get checkboxes from it
|
|
|
|
// Deliberately omitting ,0 so oldid comes from request
|
|
|
|
$article = new Article( $title );
|
|
|
|
$editPage = new EditPage( $article );
|
|
|
|
$result = $editPage->makeTemplatesOnThisPageList( $editPage->getTemplates() );
|
|
|
|
break;
|
|
|
|
|
2013-05-15 23:51:11 +00:00
|
|
|
case 'parsefragment':
|
2014-10-22 22:47:21 +00:00
|
|
|
$wikitext = $params['wikitext'];
|
2021-04-14 14:05:36 +00:00
|
|
|
if ( $wikitext === null ) {
|
|
|
|
$this->dieWithError( [ 'apierror-missingparam', 'wikitext' ] );
|
|
|
|
}
|
2014-10-22 22:47:21 +00:00
|
|
|
if ( $params['pst'] ) {
|
2015-03-26 19:32:01 +00:00
|
|
|
$wikitext = $this->pstWikitext( $title, $wikitext );
|
2014-10-22 22:47:21 +00:00
|
|
|
}
|
2020-07-22 13:38:33 +00:00
|
|
|
$content = $this->transformWikitext(
|
2022-10-03 10:48:43 +00:00
|
|
|
$title, $wikitext, true
|
2019-04-05 13:51:14 +00:00
|
|
|
)['body'];
|
2023-11-03 16:05:08 +00:00
|
|
|
Assert::postcondition( is_string( $content ), 'Content expected' );
|
|
|
|
$result = [
|
|
|
|
'result' => 'success',
|
|
|
|
'content' => $content
|
|
|
|
];
|
2013-05-15 23:51:11 +00:00
|
|
|
break;
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $result );
|
|
|
|
}
|
|
|
|
|
2016-04-29 16:00:57 +00:00
|
|
|
/**
|
|
|
|
* Check if the configured allowed namespaces include the specified namespace
|
|
|
|
*
|
2021-06-04 11:58:18 +00:00
|
|
|
* @param Config $config
|
2016-04-29 16:00:57 +00:00
|
|
|
* @param int $namespaceId Namespace ID
|
2017-07-25 14:49:56 +00:00
|
|
|
* @return bool
|
2016-04-29 16:00:57 +00:00
|
|
|
*/
|
2024-02-20 10:27:15 +00:00
|
|
|
public static function isAllowedNamespace( Config $config, int $namespaceId ): bool {
|
2023-06-07 12:26:10 +00:00
|
|
|
return in_array( $namespaceId, self::getAvailableNamespaceIds( $config ), true );
|
2016-06-01 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of allowed namespace IDs
|
|
|
|
*
|
2021-06-04 11:58:18 +00:00
|
|
|
* @param Config $config
|
2021-10-01 12:00:56 +00:00
|
|
|
* @return int[]
|
2016-06-01 16:06:22 +00:00
|
|
|
*/
|
2024-02-20 10:27:15 +00:00
|
|
|
public static function getAvailableNamespaceIds( Config $config ): array {
|
2021-10-01 12:00:56 +00:00
|
|
|
$namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
|
|
|
$configuredNamespaces = array_replace(
|
|
|
|
ExtensionRegistry::getInstance()->getAttribute( 'VisualEditorAvailableNamespaces' ),
|
|
|
|
$config->get( 'VisualEditorAvailableNamespaces' )
|
|
|
|
);
|
|
|
|
$normalized = [];
|
|
|
|
foreach ( $configuredNamespaces as $id => $enabled ) {
|
2016-06-01 16:06:22 +00:00
|
|
|
// Convert canonical namespace names to IDs
|
2021-10-01 12:00:56 +00:00
|
|
|
$id = $namespaceInfo->getCanonicalIndex( strtolower( $id ) ) ?? $id;
|
|
|
|
$normalized[$id] = $enabled && $namespaceInfo->exists( $id );
|
|
|
|
}
|
|
|
|
ksort( $normalized );
|
|
|
|
return array_keys( array_filter( $normalized ) );
|
2016-04-21 11:40:42 +00:00
|
|
|
}
|
2016-04-29 16:00:57 +00:00
|
|
|
|
2016-04-21 11:40:42 +00:00
|
|
|
/**
|
|
|
|
* Check if the configured allowed content models include the specified content model
|
|
|
|
*
|
2021-06-04 11:58:18 +00:00
|
|
|
* @param Config $config
|
2016-04-21 11:40:42 +00:00
|
|
|
* @param string $contentModel Content model ID
|
2017-07-25 14:49:56 +00:00
|
|
|
* @return bool
|
2016-04-21 11:40:42 +00:00
|
|
|
*/
|
2024-02-20 10:27:15 +00:00
|
|
|
public static function isAllowedContentType( Config $config, string $contentModel ): bool {
|
2016-06-01 16:06:22 +00:00
|
|
|
$availableContentModels = array_merge(
|
|
|
|
ExtensionRegistry::getInstance()->getAttribute( 'VisualEditorAvailableContentModels' ),
|
|
|
|
$config->get( 'VisualEditorAvailableContentModels' )
|
|
|
|
);
|
2021-10-01 12:00:56 +00:00
|
|
|
return (bool)( $availableContentModels[$contentModel] ?? false );
|
2016-04-29 16:00:57 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
public function getAllowedParams() {
|
2016-02-17 16:18:02 +00:00
|
|
|
return [
|
|
|
|
'page' => [
|
2020-07-20 20:43:59 +00:00
|
|
|
ParamValidator::PARAM_REQUIRED => true,
|
2016-02-17 16:18:02 +00:00
|
|
|
],
|
2019-10-14 19:49:02 +00:00
|
|
|
'badetag' => null,
|
2016-02-17 16:18:02 +00:00
|
|
|
'format' => [
|
2020-07-20 20:43:59 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => 'jsonfm',
|
|
|
|
ParamValidator::PARAM_TYPE => [ 'json', 'jsonfm' ],
|
2016-02-17 16:18:02 +00:00
|
|
|
],
|
|
|
|
'paction' => [
|
2020-07-20 20:43:59 +00:00
|
|
|
ParamValidator::PARAM_REQUIRED => true,
|
|
|
|
ParamValidator::PARAM_TYPE => [
|
2014-03-21 00:44:30 +00:00
|
|
|
'parse',
|
2015-03-13 22:15:17 +00:00
|
|
|
'metadata',
|
2019-02-22 18:50:46 +00:00
|
|
|
'templatesused',
|
2016-05-26 12:08:26 +00:00
|
|
|
'wikitext',
|
2014-03-21 00:44:30 +00:00
|
|
|
'parsefragment',
|
2016-02-17 16:18:02 +00:00
|
|
|
],
|
|
|
|
],
|
2020-06-10 16:08:23 +00:00
|
|
|
'wikitext' => [
|
2020-07-20 20:43:59 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'text',
|
|
|
|
ParamValidator::PARAM_DEFAULT => null,
|
2020-06-10 16:08:23 +00:00
|
|
|
],
|
2016-09-06 19:16:55 +00:00
|
|
|
'section' => null,
|
2022-04-19 19:53:03 +00:00
|
|
|
'stash' => false,
|
2022-09-02 00:58:15 +00:00
|
|
|
'oldid' => [
|
|
|
|
ParamValidator::PARAM_TYPE => 'integer',
|
|
|
|
],
|
2016-12-31 17:02:33 +00:00
|
|
|
'editintro' => null,
|
2014-10-22 22:47:21 +00:00
|
|
|
'pst' => false,
|
2017-09-14 20:08:09 +00:00
|
|
|
'preload' => null,
|
2017-09-25 15:56:42 +00:00
|
|
|
'preloadparams' => [
|
2020-07-20 20:43:59 +00:00
|
|
|
ParamValidator::PARAM_ISMULTI => true,
|
2017-09-25 15:56:42 +00:00
|
|
|
],
|
2016-02-17 16:18:02 +00:00
|
|
|
];
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
public function needsToken() {
|
2013-07-11 17:09:28 +00:00
|
|
|
return false;
|
2012-11-14 18:33:57 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2014-10-14 00:20:50 +00:00
|
|
|
public function isInternal() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2012-11-14 18:33:57 +00:00
|
|
|
public function isWriteMode() {
|
2016-03-10 18:58:41 +00:00
|
|
|
return false;
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|
|
|
|
}
|