From: Daniel Kinzler Date: Fri, 23 Mar 2012 15:44:49 +0000 (+0000) Subject: $wgContentHandlerTextFallback X-Git-Tag: 1.31.0-rc.0~22097^2^2~282 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=01b304038c96367eb5e364292016c80257f2de0e;p=lhc%2Fweb%2Fwiklou.git $wgContentHandlerTextFallback --- diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index d784a7c3a5..67bc81206d 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -14,19 +14,17 @@ abstract class ContentHandler { public static function getContentText( Content $content = null ) { + global $wgContentHandlerTextFallback; + if ( !$content ) return ''; if ( $content instanceof TextContent ) { - #XXX: or check by model name? - #XXX: or define $content->allowRawData()? - #XXX: or define $content->getDefaultWikiText()? return $content->getNativeData(); } - #XXX: this must not be used for editing, otherwise we may loose data: - #XXX: e.g. if this returns the "main" text from a multipart page, all attachments would be lost + if ( $wgContentHandlerTextFallback == 'fail' ) throw new MWException( "Attempt to get text from Content with model " . $content->getModelName() ); + if ( $wgContentHandlerTextFallback == 'serialize' ) return $content->serialize(); - #TODO: log this incident! return null; } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9536258580..1e5edbfc30 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5750,6 +5750,22 @@ $wgSeleniumConfigFile = null; $wgDBtestuser = ''; //db user that has permission to create and drop the test databases only $wgDBtestpassword = ''; +/** + * Associative array mapping namespace IDs to the name of the content model pages in that namespace should have by + * default (use the CONTENT_MODEL_XXX constants). If no special content type is defined for a given namespace, + * pages in that namespace will use the CONTENT_MODEL_WIKITEXT (except for the special case of JS and CS pages). + */ +$wgNamespaceContentModels = array(); + +/** + * How to react if a plain text version of a non-text Content object is requested using ContentHandler::getContentText(): + * + * * 'ignore': return null + * * 'fail': throw an MWException + * * 'serialize': serialize to default format + */ +$wgContentHandlerTextFallback = 'ignore'; + /** * For really cool vim folding this needs to be at the end: * vim: foldmarker=@{,@} foldmethod=marker