Fix outputting AJAX
authorMatěj Grabovský <mgrabovsky@users.mediawiki.org>
Sat, 18 Jun 2011 21:13:46 +0000 (21:13 +0000)
committerMatěj Grabovský <mgrabovsky@users.mediawiki.org>
Sat, 18 Jun 2011 21:13:46 +0000 (21:13 +0000)
When calling remote functions, MW was outputting the result followed by page HTML. This was caused by calling the cleanup function, which also output the HTML, even after an AJAX request. Fixed by moving the call after AJAX is all safely handled.

includes/Wiki.php

index dafae67..f3d1c6d 100644 (file)
@@ -494,7 +494,6 @@ class MediaWiki {
                try {
                        $this->checkMaxLag( true );
                        $this->main();
-                       $this->finalCleanup();
                        $this->restInPeace();
                } catch ( Exception $e ) {
                        MWExceptionHandler::handle( $e );
@@ -548,7 +547,7 @@ class MediaWiki {
                
                # Set title from request parameters
                $wgTitle = $this->getTitle();
-               $action = $this->context->getRequest()->getVal( 'action', 'view' );
+               $action = $this->getAction();
                
                # Send Ajax requests to the Ajax dispatcher.
                if ( $wgUseAjax && $action == 'ajax' ) {
@@ -584,6 +583,7 @@ class MediaWiki {
                }
                
                $this->performRequest();
+               $this->finalCleanup();
                
                wfProfileOut( __METHOD__ );
        }