Page MenuHomePhabricator

Can't save non-default content model with $wgContentHandlerUseDB disabled: model is wikitext , default for EtherpadLite:Pad.modals.initsocketfail.cause/fr is text
Closed, InvalidPublic

Description

Can't save non-default content model with $wgContentHandlerUseDB disabled: model is wikitext , default for EtherpadLite:Pad.modals.initsocketfail.cause/fr is text
Backtrace:
#0 /www/dev.translatewiki.net/w/includes/Revision.php(1262): Revision->checkContentModel()
#1 /www/dev.translatewiki.net/w/includes/WikiPage.php(1852): Revision->insertOn(Object(DatabaseMysql))
#2 /www/dev.translatewiki.net/w/includes/WikiPage.php(1571): WikiPage->doEditContent(Object(TextContent), 'Importing a new...', 48, false, Object(User))
#3 [internal function]: WikiPage->doEdit('La cause de ce ...', 'Importing a new...', 48, false, Object(User))
#4 /www/dev.translatewiki.net/w/includes/Article.php(1944): call_user_func_array(Array, Array)
#5 /www/dev.translatewiki.net/w/extensions/Translate/utils/MessageUpdateJob.php(40): Article->__call('doEdit', Array)
#6 /www/dev.translatewiki.net/w/extensions/Translate/utils/MessageUpdateJob.php(40): Article->doEdit('La cause de ce ...', 'Importing a new...', 48, false, Object(User))
#7 /www/dev.translatewiki.net/w/maintenance/runJobs.php(83): MessageUpdateJob->run()
#8 /www/dev.translatewiki.net/w/maintenance/doMaintenance.php(110): RunJobs->execute()
#9 /www/dev.translatewiki.net/w/maintenance/runJobs.php(116): require_once('/www/dev.transl...')
#10 {main}

I've had this code in my LocalSettings for a while:

$wgHooks['ContentHandlerDefaultModelFor'][] = function( $title, &$model ) {
if ( $title->getNamespace() >= 1200 ) {

		$model = CONTENT_MODEL_TEXT;

}
return true;
};

Somehow the code seems to be treating pages with trailing whitespace differently from other pages.


Version: 1.21.x
Severity: normal

Details

Reference
bz42291

Event Timeline

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

Apparently it is not trailing whitespace. I thought so because the first one was:
Can't save non-default content model with $wgContentHandlerUseDB disabled: model is wikitext , default for EtherpadLite:Pad.share.link/fr is text
Backtrace:
#0 /www/dev.translatewiki.net/w/includes/Revision.php(1262): Revision->checkContentModel()
#1 /www/dev.translatewiki.net/w/includes/WikiPage.php(1852): Revision->insertOn(Object(DatabaseMysql))
#2 /www/dev.translatewiki.net/w/includes/WikiPage.php(1571): WikiPage->doEditContent(Object(TextContent), 'Importing a new...', 48, false, Object(User))
#3 [internal function]: WikiPage->doEdit('Lien ', 'Importing a new...', 48, false, Object(User))
#4 /www/dev.translatewiki.net/w/includes/Article.php(1944): call_user_func_array(Array, Array)
#5 /www/dev.translatewiki.net/w/extensions/Translate/utils/MessageUpdateJob.php(40): Article->__call('doEdit', Array)
#6 /www/dev.translatewiki.net/w/extensions/Translate/utils/MessageUpdateJob.php(40): Article->doEdit('Lien ', 'Importing a new...', 48, false, Object(User))
#7 /www/dev.translatewiki.net/w/maintenance/runJobs.php(83): MessageUpdateJob->run()
#8 /www/dev.translatewiki.net/w/maintenance/doMaintenance.php(110): RunJobs->execute()
#9 /www/dev.translatewiki.net/w/maintenance/runJobs.php(116): require_once('/www/dev.transl...')
#10 {main}

So it is even more mysterious while most of the messages work fine, but these few fail.

Sorry for going back and worth, it is the trailing whitespace, content was just truncated in the above backtrace.

Some extension tells mediawiki that this page is not wikitext (probably using the TitleIsWikitextPage hook). Then, something else tries to save content of the page, telling mediawiki that the content *is* wikitext. But $wgContentHandlerUseDB = false gives mediawiki no way to record that fact, so it fails.

If the content of the page really is not wikitext, but (as currently assumed) plain text, set the content model accordingly when editing.

Ah, sorry, didn't look at your code right. It's of course not TitleIsWikitextPage in that case but your handler for ContentHandlerDefaultModelFor telling mediawiki that this page isn't wikitext.

The question is now, when where and why it is treated as wikitext and fails.

Jdforrester-WMF added a subscriber: Jdforrester-WMF.

wgContentHandlerUseDB has been deprecated as of MediaWiki 1.34 and removed as of MediaWiki 1.35.