Page MenuHomePhabricator

Cannot edit a JS page with wikitext content model
Open, Needs TriagePublic

Description

Today I came across this page on itwiki which has a peculiar (but not so rare) trait: the content of the page is JavaScript, but its content model is wikitext. Since I'm an interface-admin on itwiki, I expect to be able to edit that page, but if I hit the edit button [1] I see the following error:

You cannot edit this revision because its content model is javascript, which differs from the current content model of the page wikitext.

Reading that, the most natural thing to do seems to change the page's content model to JavaScript. However, if I try to change the content model to JS, I get the following error message:

Your edit was ignored because no change was made to the text.

Now this is confusing, because I wasn't supposed to change anything in the page text, only its content model.
I finally managed to edit the page by changing the content model to plain text (adding a .js to the title) and then switching back to the JavaScript content model. However this is just some sort of a trick and it shouldn't really be that difficult to edit such a page.

UPDATE: Actually, even if I got the error from Special:ChangeContentModel, the model has been changed. See also the logs for this page, for which I had the same problem.

[1] Side note: it really says "Edit source", and not "View source".

Event Timeline

Those pages should probably be elminated (see T171563: Only allow MediaWiki, Gadget, and User namespace pages to be treated as JS or CSS (no project namespace, etc.)) but the error message was intended for editing old revisions when the current revision has a different content model, so if you got it in some other situation that's a bug. The code seems correct at a glance (contentmodelediterror error in EditPage::edit()) and I can't reproduce.

The other warning (edit-no-change) is set in PageUpdater::doModify(); it probably shouldn't do that when the content model has changed. I can't reproduce that either; might have been one of the MCR-related bugs which have been fixed since, we had at least one related to null edit detection recently.

As for the tab text, you have permission to edit the page, but you are prevented from using the old revision for a usability reason (as you'd end up changing the content model, probably without understanding what you are doing). That's a restriction that is handled outside the permission system so the various places generating edit links don't handle it well.

True, in fact I was performing some maintenance aiming to delete such pages :-)

the error message was intended for editing old revisions when the current revision has a different content model, so if you got it in some other situation that's a bug.

I got it for the current revision, with the content model being wikitext and the page content being JS. The last revision was from 2014. I suspect that some change happened in between affected existing pages making this bug appear, while it doesn't for newly created pages; maybe that's why you cannot reproduce the issue. Currently, I cannot find other pages like that on itwiki, so I don't have any more examples.

The other warning (edit-no-change) is set in PageUpdater::doModify(); it probably shouldn't do that when the content model has changed.

Agreed.

might have been one of the MCR-related bugs which have been fixed since

Could be.

As for the tab text, you have permission to edit the page, but you are prevented from using the old revision for a usability reason (as you'd end up changing the content model, probably without understanding what you are doing). That's a restriction that is handled outside the permission system so the various places generating edit links don't handle it well.

Yeah I imagined it could be something like that, not a big deal anyway.