Mainframe98 has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/358425 )
Change subject: Fix the exception thrown when using the tool on unsupported
content models
......................................................................
Fix the exception thrown when using the tool on unsupported content models
The exception appears when the ParserMigration tool is used on pages with
the flowboard content model. Since ParserMigration aims to migrate to a
new parser, it should only target pages that actually utilize the
parser, so anything that does not use the wikitext content model has no
reason to use the migration tool.
The error message is borrowed from RawAction.php to remain consistent.
Bug: T167722
Change-Id: Ib129e61c04288da366bc018625be2dddc8bdb687
---
M extension.json
M includes/Hooks.php
M includes/MigrationEditPage.php
3 files changed, 16 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ParserMigration
refs/changes/25/358425/1
diff --git a/extension.json b/extension.json
index 0f9c888..bdb3d99 100644
--- a/extension.json
+++ b/extension.json
@@ -1,7 +1,7 @@
{
"name": "ParserMigration",
"author": "Tim Starling",
- "version": "1.0.0",
+ "version": "1.0.1",
"url": "https://www.mediawiki.org/wiki/Extension:ParserMigration",
"descriptionmsg": "parsermigration-desc",
"license-name": "CC0-1.0",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 4b95588..ca75be0 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -27,7 +27,8 @@
$out = $skin->getOutput();
$title = $skin->getTitle();
$user = $skin->getUser();
- if ( $out->isArticleRelated() && $user->getOption(
'parsermigration' ) ) {
+ if ( $out->isArticleRelated() && $title->getContentModel() ===
CONTENT_MODEL_WIKITEXT &&
+ $user->getOption( 'parsermigration' ) ) {
$toolbox['parsermigration'] = [
'href' => $title->getLocalURL( [ 'action' =>
'parsermigration-edit' ] ),
'text' => $skin->msg(
'parsermigration-toolbox-label' )->text(),
diff --git a/includes/MigrationEditPage.php b/includes/MigrationEditPage.php
index a42ad14..a8b8da8 100644
--- a/includes/MigrationEditPage.php
+++ b/includes/MigrationEditPage.php
@@ -5,6 +5,19 @@
class MigrationEditPage extends \EditPage {
public function __construct( \IContextSource $context, \Title $title ) {
+ // Display an error if the action is not possible for content
model associated with this
+ // title as is not wikitext (similar to RawAction::getRawText())
+ if ( $title->getContentModel() !== CONTENT_MODEL_WIKITEXT ) {
+ $contentModel = \ContentHandler::getLocalizedName(
CONTENT_MODEL_WIKITEXT,
+ \Language::factory( 'en' ) );
+
+ wfHttpError( 415, "Unsupported Media Type",
+ "The requested page uses the content model `" .
+ $contentModel . "` which is not supported via this
interface."
+ );
+ die();
+ }
+
$article = \Article::newFromTitle( $title, $context );
parent::__construct( $article );
$this->setContextTitle( $title );
--
To view, visit https://gerrit.wikimedia.org/r/358425
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib129e61c04288da366bc018625be2dddc8bdb687
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ParserMigration
Gerrit-Branch: master
Gerrit-Owner: Mainframe98 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits