From 0e507f630a561c01bc00673a6abf03908d076083 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 9 Oct 2012 14:58:25 +0200 Subject: [PATCH] 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 --- includes/EditPage.php | 9 +++++++-- includes/content/TextContent.php | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) 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; } -- 2.20.1