From: aude Date: Tue, 23 Oct 2012 15:42:20 +0000 (+0000) Subject: per bug 41244 and 41303, handle null or false params in TextContent constructor X-Git-Tag: 1.31.0-rc.0~21894^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=a17660fbd08d5075daa17f98a09ff86eadd64d04;p=lhc%2Fweb%2Fwiklou.git per bug 41244 and 41303, handle null or false params in TextContent constructor Instead of throwing exception in these cases (which there are use cases for), create an empty TextContent object. Change-Id: Ice30ea78428d95805aa56cd3a35405aa67ad10ab --- diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 74c5a882cd..048ac396d3 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -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." ); }