Add wfErrorLog() call before throwing an exception in readStyleFile
[lhc/web/wiklou.git] / includes / EditPage.php
index 35328f8..cc41b02 100644 (file)
@@ -381,7 +381,6 @@ class EditPage {
                $this->isCssSubpage         = $this->mTitle->isCssSubpage();
                $this->isJsSubpage          = $this->mTitle->isJsSubpage();
                $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
-               $this->isNew                = !$this->mTitle->exists() || $this->section == 'new';
 
                # Show applicable editing introductions
                if ( $this->formtype == 'initial' || $this->firsttime ) {
@@ -588,12 +587,13 @@ class EditPage {
         * @param $request WebRequest
         */
        function importFormData( &$request ) {
-               global $wgLang, $wgUser;
+               global $wgContLang, $wgUser;
 
                wfProfileIn( __METHOD__ );
 
                # Section edit can come from either the form or a link
                $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
+               $this->isNew = !$this->mTitle->exists() || $this->section == 'new';
 
                if ( $request->wasPosted() ) {
                        # These fields need to be checked for encoding.
@@ -612,7 +612,7 @@ class EditPage {
                        }
 
                        # Truncate for whole multibyte characters
-                       $this->summary = $wgLang->truncate( $request->getText( 'wpSummary' ), 255 );
+                       $this->summary = $wgContLang->truncate( $request->getText( 'wpSummary' ), 255 );
 
                        # If the summary consists of a heading, e.g. '==Foobar==', extract the title from the
                        # header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
@@ -624,7 +624,7 @@ class EditPage {
                        # currently doing double duty as both edit summary and section title. Right now this
                        # is just to allow API edits to work around this limitation, but this should be
                        # incorporated into the actual edit form when EditPage is rewritten (Bugs 18654, 26312).
-                       $this->sectiontitle = $wgLang->truncate( $request->getText( 'wpSectionTitle' ), 255 );
+                       $this->sectiontitle = $wgContLang->truncate( $request->getText( 'wpSectionTitle' ), 255 );
                        $this->sectiontitle = preg_replace( '/^\s*=+\s*(.*?)\s*=+\s*$/', '$1', $this->sectiontitle );
 
                        $this->edittime = $request->getVal( 'wpEdittime' );
@@ -806,10 +806,10 @@ class EditPage {
         * @param $def_text string
         * @return mixed string on success, $def_text for invalid sections
         * @private
-        * @deprecated since 1.21
+        * @deprecated since 1.21, get WikiPage::getContent() instead.
         */
        function getContent( $def_text = false ) {
-               wfDeprecated( __METHOD__, '1.21' );
+               ContentHandler::deprecated( __METHOD__, '1.21' );
 
                if ( $def_text !== null && $def_text !== false && $def_text !== '' ) {
                        $def_content = $this->toEditContent( $def_text );
@@ -989,10 +989,10 @@ class EditPage {
         * Use this method before edit() to preload some text into the edit box
         *
         * @param $text string
-        * @deprecated since 1.21
+        * @deprecated since 1.21, use setPreloadedContent() instead.
         */
        public function setPreloadedText( $text ) {
-               wfDeprecated( __METHOD__, "1.21" );
+               ContentHandler::deprecated( __METHOD__, "1.21" );
 
                $content = $this->toEditContent( $text );
 
@@ -1007,7 +1007,7 @@ class EditPage {
         * @since 1.21
         */
        public function setPreloadedContent( Content $content ) {
-               $this->mPreloadedContent = $content;
+               $this->mPreloadContent = $content;
        }
 
        /**
@@ -1021,7 +1021,7 @@ class EditPage {
         * @deprecated since 1.21, use getPreloadedContent() instead
         */
        protected function getPreloadedText( $preload ) {
-               wfDeprecated( __METHOD__, "1.21" );
+               ContentHandler::deprecated( __METHOD__, "1.21" );
 
                $content = $this->getPreloadedContent( $preload );
                $text = $this->toEditText( $content );
@@ -1643,7 +1643,7 @@ class EditPage {
         * @deprecated since 1.21, use mergeChangesIntoContent() instead
         */
        function mergeChangesInto( &$editText ){
-               wfDebug( __METHOD__, "1.21" );
+               ContentHandler::deprecated( __METHOD__, "1.21" );
 
                $editContent = $this->toEditContent( $editText );
 
@@ -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 );