Fix creation of pages in the MediaWiki namespace.
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 9 Oct 2012 12:58:25 +0000 (14:58 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 9 Oct 2012 12:58:25 +0000 (14:58 +0200)
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
includes/content/TextContent.php

index 35328f8..f7d9e3f 100644 (file)
@@ -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 );
 
index 68e6c39..e98584f 100644 (file)
@@ -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;
        }