Page MenuHomePhabricator

Cannot edit old revisions if the content model of those revisions are different from the page's current revision
Closed, ResolvedPublic

Description

2014-09-23 02:55:34 mw1020 mediawikiwiki: [acd305b3] /w/index.php?title=Project:Sandbox&action=edit&oldid=1176667 Exception from line 594 of /srv/mediawiki/php-1.24wmf22/includes/content/ContentHandler.php: Format text/x-wiki is not supported for content model css
#0 /srv/mediawiki/php-1.24wmf22/includes/content/TextContentHandler.php(49): ContentHandler->checkFormat()
#1 /srv/mediawiki/php-1.24wmf22/includes/content/AbstractContent.php(151): TextContentHandler->serializeContent()
#2 /srv/mediawiki/php-1.24wmf22/includes/EditPage.php(2246): AbstractContent->serialize()
#3 /srv/mediawiki/php-1.24wmf22/includes/EditPage.php(938): EditPage->toEditText()
#4 /srv/mediawiki/php-1.24wmf22/includes/EditPage.php(532): EditPage->initialiseForm()
#5 /srv/mediawiki/php-1.24wmf22/includes/actions/EditAction.php(56): EditPage->edit()
#6 /srv/mediawiki/php-1.24wmf22/includes/MediaWiki.php(414): EditAction->show()
#7 /srv/mediawiki/php-1.24wmf22/includes/MediaWiki.php(282): MediaWiki->performAction()
#8 /srv/mediawiki/php-1.24wmf22/includes/MediaWiki.php(584): MediaWiki->performRequest()
#9 /srv/mediawiki/php-1.24wmf22/includes/MediaWiki.php(435): MediaWiki->main()
#10 /srv/mediawiki/php-1.24wmf22/index.php(46): MediaWiki->run()
#11 /srv/mediawiki/w/index.php(3): include()
#12 {main}


Version: unspecified
Severity: normal
URL: https://www.mediawiki.org/w/index.php?title=Project:Sandbox&action=edit&oldid=1176667
See Also:
{73490}
T72901: Users can change the content model of other users' user pages to CSS or JS

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:48 AM
bzimport set Reference to bz71163.
bzimport added a subscriber: Unknown Object (MLST).

Reproduction case:

Create a page with JSON content model
Make a few edits
Convert page to wikitext content model
Try going to action=edit&oldid=### where the oldid you use is from where the revision is JSON
Exception is thrown.

https://www.mediawiki.org/w/index.php?title=User%3ALegoktm%2Ftest&diff=1257300&oldid=1236737

Pressing undo or edit (on the left edit) throws a fatal as well.

EBernhardson subscribed.

@daniel You would be most familiar with ContentHandler, what needs to happen to support this use case?

He7d3r set Security to None.

This is related to T104033: Populate rev_content_model and rev_content_format when saving. We do not set a rev_content_model/rev_content_format when saving if they are the default, and when the page's model is changed, the revisions need to be updated to explicitly reference the old model.

Ignore what I said. This is unrelated...

We try to serialize the Content into text using the current default format of the page. If the revision is JavaScript and the page is currently JSON, it will try serializing JavaScript as application/json, which will fail. I think we should just show a read only "View source" page and serialize using the revision's content format. Thoughts?

Change 237988 had a related patch set uploaded (by Legoktm):
Handle revisions with different content models in EditPage

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

Change 237988 merged by jenkins-bot:
Handle revisions with different content models in EditPage

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

Legoktm assigned this task to wctaiwan.