per bug 41244 and 41303, handle null or false params in TextContent constructor
authoraude <aude.wiki@gmail.com>
Tue, 23 Oct 2012 15:42:20 +0000 (15:42 +0000)
committeraude <aude.wiki@gmail.com>
Tue, 23 Oct 2012 15:42:20 +0000 (15:42 +0000)
Instead of throwing exception in these cases (which there are use cases for),
create an empty TextContent object.

Change-Id: Ice30ea78428d95805aa56cd3a35405aa67ad10ab

includes/content/TextContent.php

index 74c5a88..048ac39 100644 (file)
@@ -32,6 +32,10 @@ class TextContent extends AbstractContent {
        public function __construct( $text, $model_id = CONTENT_MODEL_TEXT ) {
                parent::__construct( $model_id );
 
+               if ( $text === null || $text === false ) {
+                       $text = '';
+               }
+
                if ( !is_string( $text ) ) {
                        throw new MWException( "TextContent expects a string in the constructor." );
                }