Merge "EditPage: Allow the 'save' button's label to be 'publish' for public wikis"
[lhc/web/wiklou.git] / includes / MediaWiki.php
index ee03f02..77ac76a 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * The MediaWiki class is the helper class for the index.php entry point.
@@ -761,12 +762,17 @@ class MediaWiki {
         * @param string $mode Use 'fast' to always skip job running
         */
        public function restInPeace( $mode = 'fast' ) {
+               $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                // Assure deferred updates are not in the main transaction
-               wfGetLBFactory()->commitMasterChanges( __METHOD__ );
+               $factory->commitMasterChanges( __METHOD__ );
 
-               // Ignore things like master queries/connections on GET requests
-               // as long as they are in deferred updates (which catch errors).
-               Profiler::instance()->getTransactionProfiler()->resetExpectations();
+               // Loosen DB query expectations since the HTTP client is unblocked
+               $trxProfiler = Profiler::instance()->getTransactionProfiler();
+               $trxProfiler->resetExpectations();
+               $trxProfiler->setExpectations(
+                       $this->config->get( 'TrxProfilerLimits' )['PostSend'],
+                       __METHOD__
+               );
 
                // Do any deferred jobs
                DeferredUpdates::doUpdates( 'enqueue' );
@@ -784,7 +790,6 @@ class MediaWiki {
                wfLogProfilingData();
 
                // Commit and close up!
-               $factory = wfGetLBFactory();
                $factory->commitMasterChanges( __METHOD__ );
                $factory->shutdown( LBFactory::SHUTDOWN_NO_CHRONPROT );
 
@@ -798,10 +803,10 @@ class MediaWiki {
         */
        public function triggerJobs() {
                $jobRunRate = $this->config->get( 'JobRunRate' );
-               if ( $jobRunRate <= 0 || wfReadOnly() ) {
-                       return;
-               } elseif ( $this->getTitle()->isSpecial( 'RunJobs' ) ) {
+               if ( $this->getTitle()->isSpecial( 'RunJobs' ) ) {
                        return; // recursion guard
+               } elseif ( $jobRunRate <= 0 || wfReadOnly() ) {
+                       return;
                }
 
                if ( $jobRunRate < 1 ) {
@@ -838,7 +843,7 @@ class MediaWiki {
                        $query, $this->config->get( 'SecretKey' ) );
 
                $errno = $errstr = null;
-               $info = wfParseUrl( $this->config->get( 'Server' ) );
+               $info = wfParseUrl( $this->config->get( 'CanonicalServer' ) );
                MediaWiki\suppressWarnings();
                $host = $info['host'];
                $port = 80;
@@ -867,7 +872,8 @@ class MediaWiki {
                        return;
                }
 
-               $url = wfAppendQuery( wfScript( 'index' ), $query );
+               $special = SpecialPageFactory::getPage( 'RunJobs' );
+               $url = $special->getPageTitle()->getCanonicalURL( $query );
                $req = (
                        "POST $url HTTP/1.1\r\n" .
                        "Host: {$info['host']}\r\n" .
@@ -878,7 +884,7 @@ class MediaWiki {
                $runJobsLogger->info( "Running $n job(s) via '$url'" );
                // Send a cron API request to be performed in the background.
                // Give up if this takes too long to send (which should be rare).
-               stream_set_timeout( $sock, 1 );
+               stream_set_timeout( $sock, 2 );
                $bytes = fwrite( $sock, $req );
                if ( $bytes !== strlen( $req ) ) {
                        $runJobsLogger->error( "Failed to start cron API (socket write error)" );