Page MenuHomePhabricator

Using Special:SimulateTwoColEditConflict on Wikibase entity page shows internal JSON serialization and then throws MWException
Closed, ResolvedPublic

Description

  1. Open wikidata:Special:SimulateTwoColEditConflict.
  2. Enter the title of a Wikibase entity page, e. g. Q42 or Property:P31, and submit the form. You will see an editor for wikitext, filled with the internal JSON serialization of the entity.
  3. Make some edits to the “wikitext” (it doesn’t seem to matter if they make the JSON invalid or not) and submit the form. You will be redirected to an “internal error” page for a “Fatal exception of type "MWException"”.

This should probably be prevented at step 2 – the form should reject titles of pages whose content model isn’t wikitext.

Event Timeline

Restricted Application added a project: archived--TCB-Team. · View Herald TranscriptDec 12 2017, 12:05 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The same thing also happens, for instance, for Structured Discussions pages (e. g. “User talk:Lucas Werkmeister (WMDE)” on Wikidata). (I assume Structured Discussions also uses a different content model.)

Beginnings of a fix:

diff --git a/includes/SpecialConflictTestPage/SpecialConflictTestPage.php b/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
index fa536d7..80a5420 100644
--- a/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
+++ b/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
@@ -56,6 +56,13 @@ public function execute( $subPage ) {
 		}
 
 		$testArticle = Article::newFromTitle( $testTitle, $this->getContext() );
+
+		if ( !$testArticle->getContentHandler()->supportsDirectEditing() ) {
+			$this->showWarningBox( 'twoColConflict-test-contentModel-noEditing' );
+			$this->showLoadTitle();
+			return;
+		}
+
 		if ( $request->getVal( 'mw-twocolconflict-test-text' ) === null ) {
 			$this->showHintBox( ( new Message( 'twoColConflict-test-edit-hint' ) )->parse() );

TODO: introduce the message used in the warning box (probably with a better name), probably add a test. Can I leave this to you? :)

For reference regarding the message – the API action=edit error in such a case is:

"error": {
  "code": "wikibase-no-direct-editing",
  "info": "Direct editing is disabled in namespace "
}

So perhaps the error message key here would be twoColConflict-test-no-direct-editing

Change 398270 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/TwoColConflict@master] Reject non-editable pages in test page

https://gerrit.wikimedia.org/r/398270

Change 398270 merged by jenkins-bot:
[mediawiki/extensions/TwoColConflict@master] Reject non-editable pages in conflict test page

https://gerrit.wikimedia.org/r/398270

Lucas_Werkmeister_WMDE closed this task as Resolved.Dec 18 2017, 2:44 PM
Lucas_Werkmeister_WMDE claimed this task.

Tested on enwiki beta with “User talk:Lucas Werkmeister (WMDE)” and on wikidata beta with “Q14”. Fix seems to work.