Various fixes to job running code in Wiki.php
[lhc/web/wiklou.git] / includes / Wiki.php
index 1bb9c40..56d23b1 100644 (file)
@@ -117,7 +117,7 @@ class MediaWiki {
                }
 
                // Use the main page as default title if nothing else has been provided
-               if ( $ret === null && strval( $title ) === '' && $action !== 'delete' ) {
+               if ( $ret === null && strval( $title ) === '' && !$request->getCheck( 'curid' ) && $action !== 'delete' ) {
                        $ret = Title::newMainPage();
                }
 
@@ -154,19 +154,6 @@ class MediaWiki {
                return $action;
        }
 
-       /**
-        * Create an Article object of the appropriate class for the given page.
-        *
-        * @deprecated in 1.18; use Article::newFromTitle() instead
-        * @param $title Title
-        * @param $context IContextSource
-        * @return Article object
-        */
-       public static function articleFromTitle( $title, IContextSource $context ) {
-               wfDeprecated( __METHOD__, '1.18' );
-               return Article::newFromTitle( $title, $context );
-       }
-
        /**
         * Performs the request.
         * - bad titles
@@ -458,6 +445,9 @@ class MediaWiki {
                try {
                        $this->checkMaxLag();
                        $this->main();
+                       if ( function_exists( 'fastcgi_finish_request' ) ) {
+                               fastcgi_finish_request();
+                       }
                        $this->restInPeace();
                } catch ( Exception $e ) {
                        MWExceptionHandler::handle( $e );
@@ -647,12 +637,19 @@ class MediaWiki {
                }
 
                if ( !wfShellExecDisabled() && is_executable( $wgPhpCli ) ) {
-                       // Start a background process to run some of the jobs.
-                       // This will be asynchronous on *nix though not on Windows.
+                       // Start a background process to run some of the jobs
                        wfProfileIn( __METHOD__ . '-exec' );
                        $retVal = 1;
                        $cmd = wfShellWikiCmd( "$IP/maintenance/runJobs.php", array( '--maxjobs', $n ) );
-                       wfShellExec( "$cmd &", $retVal );
+                       $cmd .= " >" . wfGetNull() . " 2>&1"; // don't hang PHP on pipes
+                       if ( wfIsWindows() ) {
+                               // Using START makes this async and also works around a bug where using
+                               // wfShellExec() with a quoted script name causes a filename syntax error.
+                               $cmd = "START /B \"bg\" $cmd";
+                       } else {
+                               $cmd = "$cmd &";
+                       }
+                       wfShellExec( $cmd, $retVal );
                        wfProfileOut( __METHOD__ . '-exec' );
                } else {
                        try {