https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114449

Revision: 114449
Author:   daniel
Date:     2012-03-23 15:44:49 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
$wgContentHandlerTextFallback 

Modified Paths:
--------------
    branches/Wikidata/phase3/includes/ContentHandler.php
    branches/Wikidata/phase3/includes/DefaultSettings.php

Modified: branches/Wikidata/phase3/includes/ContentHandler.php
===================================================================
--- branches/Wikidata/phase3/includes/ContentHandler.php        2012-03-23 
15:18:44 UTC (rev 114448)
+++ branches/Wikidata/phase3/includes/ContentHandler.php        2012-03-23 
15:44:49 UTC (rev 114449)
@@ -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;
     }
 

Modified: branches/Wikidata/phase3/includes/DefaultSettings.php
===================================================================
--- branches/Wikidata/phase3/includes/DefaultSettings.php       2012-03-23 
15:18:44 UTC (rev 114448)
+++ branches/Wikidata/phase3/includes/DefaultSettings.php       2012-03-23 
15:44:49 UTC (rev 114449)
@@ -5751,6 +5751,22 @@
 $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
  * @}


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to