Page MenuHomePhabricator

"Bad content model: expected wikitext but got javascript" while saving/stashing an edit
Open, HighPublic

Description

Error

MediaWiki version: 1.35.0-wmf.37

message
MWException: Bad content model: expected wikitext but got javascript.

Impact

Notes

Details

Request ID
35714809-dd50-47c5-9b37-2fa00d4a7bf2
Request URL
https://fa.wikipedia.org/w/api.php
Stack Trace
exception.trace
#0 /srv/mediawiki/php-1.35.0-wmf.37/includes/content/TextContentHandler.php(70): ContentHandler->checkModelID(string)
#1 /srv/mediawiki/php-1.35.0-wmf.37/includes/api/ApiStashEdit.php(120): TextContentHandler->merge3(WikitextContent, WikitextContent, JavaScriptContent)
#2 /srv/mediawiki/php-1.35.0-wmf.37/includes/api/ApiMain.php(1585): ApiStashEdit->execute()
#3 /srv/mediawiki/php-1.35.0-wmf.37/includes/api/ApiMain.php(525): ApiMain->executeAction()
#4 /srv/mediawiki/php-1.35.0-wmf.37/includes/api/ApiMain.php(496): ApiMain->executeActionWithErrorHandling()
#5 /srv/mediawiki/php-1.35.0-wmf.37/api.php(84): ApiMain->execute()
#6 /srv/mediawiki/w/api.php(3): require(string)
#7 {main}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 17 2020, 6:15 PM
Krinkle renamed this task from Bad content model: expected wikitext but got javascript. to MWException: "Bad content model: expected wikitext but got javascript" (ContentHandler.php).Jun 17 2020, 6:47 PM
Krinkle triaged this task as High priority.
Krinkle updated the task description. (Show Details)

The page was originally created in Draft namespace (default contentmodel = wikitext ). The author likely then attempted editing it, thus the revision he fetched was in wikitext contentmodel. He took like 17 minutes working on the edit, and in the meanwhile, the content model of the page was changed to javascript. Later when he wanted to save, exception was thrown in ContentHanlder since the page now has content model different from that of the fetched revision. In EditPage this is handled with 'contentmodelediterror' error, but the API is not handling it.

Ammarpad claimed this task.Jun 20 2020, 3:58 PM
Ammarpad edited projects, added MediaWiki-API; removed MediaWiki-ContentHandler.

Change 606844 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] API: Handle ContentHandler exception for content model mismatch

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

This may duplicate T206253 - unclear.

Krinkle renamed this task from MWException: "Bad content model: expected wikitext but got javascript" (ContentHandler.php) to "Bad content model: expected wikitext but got javascript" while saving/stashing an edit.Jun 24 2020, 6:22 PM