Miscellaneous profiling fixes
[lhc/web/wiklou.git] / includes / EditPage.php
index 5ab5adc..b4b82eb 100644 (file)
@@ -480,6 +480,7 @@ class EditPage {
                        throw new PermissionsError( $action, $permErrors );
                }
 
+               $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->setPageTitle( wfMessage( 'viewsource-title', $this->getContextTitle()->getPrefixedText() ) );
                $wgOut->addBacklinkSubtitle( $this->getContextTitle() );
                $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' ) );
@@ -609,7 +610,7 @@ class EditPage {
                                // modified by subclasses
                                wfProfileIn( get_class( $this ) . "::importContentFormData" );
                                $textbox1 = $this->importContentFormData( $request );
-                               if ( isset( $textbox1 ) ) {
+                               if ( $textbox1 !== null ) {
                                        $this->textbox1 = $textbox1;
                                }
 
@@ -1234,7 +1235,7 @@ class EditPage {
 
                $status = Status::newGood();
 
-               wfProfileIn( __METHOD__  );
+               wfProfileIn( __METHOD__ );
                wfProfileIn( __METHOD__ . '-checks' );
 
                if ( !wfRunHooks( 'EditPage::attemptSave', array( $this ) ) ) {
@@ -1242,16 +1243,17 @@ class EditPage {
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR;
                        wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__  );
+                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
                try {
                        # Construct Content object
                        $textbox_content = $this->toEditContent( $this->textbox1 );
-               } catch (MWContentSerializationException $ex) {
+               } catch ( MWContentSerializationException $ex ) {
                        $status->fatal( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
                        $status->value = self::AS_PARSE_ERROR;
+                       wfProfileOut( __METHOD__ . '-checks' );
                        wfProfileOut( __METHOD__ );
                        return $status;
                }
@@ -1264,7 +1266,7 @@ class EditPage {
                                $status->setResult( false, $code );
 
                                wfProfileOut( __METHOD__ . '-checks' );
-                               wfProfileOut( __METHOD__  );
+                               wfProfileOut( __METHOD__ );
 
                                return $status;
                }
@@ -1671,8 +1673,7 @@ class EditPage {
        }
 
        /**
-        * @private
-        * @todo document
+        * Attempts to merge text content with base and current revisions
         *
         * @param $editText string
         *
@@ -1694,12 +1695,15 @@ class EditPage {
        }
 
        /**
-        * @private
-        * @todo document
+        * Attempts to do 3-way merge of edit content with a base revision
+        * and current content, in case of edit conflict, in whichever way appropriate
+        * for the content type.
+        *
+        * @since 1.21
         *
         * @param $editContent
+        *
         * @return bool
-        * @since since 1.WD
         */
        private function mergeChangesIntoContent( &$editContent ){
                wfProfileIn( __METHOD__ );
@@ -2194,30 +2198,8 @@ class EditPage {
                        $wgOut->addWikiMsg( 'talkpagetext' );
                }
 
-               # Optional notices on a per-namespace and per-page basis
-               $editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
-               $editnotice_ns_message = wfMessage( $editnotice_ns );
-               if ( $editnotice_ns_message->exists() ) {
-                       $wgOut->addWikiText( $editnotice_ns_message->plain() );
-               }
-               if ( MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
-                       $parts = explode( '/', $this->mTitle->getDBkey() );
-                       $editnotice_base = $editnotice_ns;
-                       while ( count( $parts ) > 0 ) {
-                               $editnotice_base .= '-' . array_shift( $parts );
-                               $editnotice_base_msg = wfMessage( $editnotice_base );
-                               if ( $editnotice_base_msg->exists() ) {
-                                       $wgOut->addWikiText( $editnotice_base_msg->plain() );
-                               }
-                       }
-               } else {
-                       # Even if there are no subpages in namespace, we still don't want / in MW ns.
-                       $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->mTitle->getDBkey() );
-                       $editnoticeMsg = wfMessage( $editnoticeText );
-                       if ( $editnoticeMsg->exists() ) {
-                               $wgOut->addWikiText( $editnoticeMsg->plain() );
-                       }
-               }
+               // Add edit notices
+               $wgOut->addHTML( implode( "\n", $this->mTitle->getEditNotices() ) );
 
                if ( $this->isConflict ) {
                        $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );