From: daniel Date: Tue, 9 Oct 2012 12:58:25 +0000 (+0200) Subject: Fix creation of pages in the MediaWiki namespace. X-Git-Tag: 1.31.0-rc.0~22066^2 X-Git-Url: http://git.cyclocoop.org/%22%20%20.%20generer_url_ecrire%28%22mots_tous%22%29%20.%20%22?a=commitdiff_plain;h=0e507f630a561c01bc00673a6abf03908d076083;p=lhc%2Fweb%2Fwiklou.git Fix creation of pages in the MediaWiki namespace. Creation of pages in the MediaWiki namespace failed with a "no such section" error if the corresponding system message did not exist. Fixed now. Change-Id: Ia6e879c66a6330ea2a63246b3aed51c9c6e1d49d --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 35328f870f..f7d9e3f182 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1921,13 +1921,18 @@ class EditPage { * an exception will be raised. Set $this->allowNonTextContent to true to allow editing of non-textual * content. * - * @param String $text Text to unserialize - * @return Content the content object created from $text + * @param String|null|false $text Text to unserialize + * @return Content The content object created from $text. If $text was false or null, false resp. null will be + * returned instead. * * @throws MWException if unserializing the text results in a Content object that is not an instance of TextContent * and $this->allowNonTextContent is not true. */ protected function toEditContent( $text ) { + if ( $text === false || $text === null ) { + return $text; + } + $content = ContentHandler::makeContent( $text, $this->getTitle(), $this->contentModel, $this->contentFormat ); diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 68e6c3913d..e98584fd8e 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -12,6 +12,10 @@ abstract class TextContent extends AbstractContent { public function __construct( $text, $model_id = null ) { parent::__construct( $model_id ); + if ( !is_string( $text ) ) { + throw new MWException( "TextContent expects a string in the constructor." ); + } + $this->mText = $text; }