mediawiki.feedback: Set the message input to be autosized
[lhc/web/wiklou.git] / includes / MediaWiki.php
index d94443b..3b463ae 100644 (file)
@@ -393,7 +393,11 @@ class MediaWiki {
                if ( $action instanceof Action ) {
                        # Let Squid cache things if we can purge them.
                        if ( $this->config->get( 'UseSquid' ) &&
-                               in_array( $request->getFullRequestURL(), $requestTitle->getSquidURLs() )
+                               in_array(
+                                       // Use PROTO_INTERNAL because that's what getSquidURLs() uses
+                                       wfExpandUrl( $request->getRequestURL(), PROTO_INTERNAL ),
+                                       $requestTitle->getSquidURLs()
+                               )
                        ) {
                                $output->setSquidMaxage( $this->config->get( 'SquidMaxage' ) );
                        }
@@ -485,6 +489,19 @@ class MediaWiki {
                $action = $this->getAction();
                $wgTitle = $title;
 
+               $trxProfiler = Profiler::instance()->getTransactionProfiler();
+
+               // Aside from rollback, master queries should not happen on GET requests.
+               // Periodic or "in passing" updates on GET should use the job queue.
+               if ( !$request->wasPosted()
+                       && in_array( $action, array( 'view', 'edit', 'history' ) )
+               ) {
+                       $trxProfiler->setExpectation( 'masterConns', 0, __METHOD__ );
+                       $trxProfiler->setExpectation( 'writes', 0, __METHOD__ );
+               } else {
+                       $trxProfiler->setExpectation( 'maxAffected', 500, __METHOD__ );
+               }
+
                // If the user has forceHTTPS set to true, or if the user
                // is in a group requiring HTTPS, or if they have the HTTPS
                // preference set, redirect them to HTTPS.
@@ -571,6 +588,10 @@ class MediaWiki {
         * Ends this task peacefully
         */
        public function restInPeace() {
+               // Ignore things like master queries/connections on GET requests
+               // as long as they are in deferred updates (which catch errors).
+               Profiler::instance()->getTransactionProfiler()->resetExpectations();
+
                // Do any deferred jobs
                DeferredUpdates::doUpdates( 'commit' );
 
@@ -608,9 +629,11 @@ class MediaWiki {
                        $n = intval( $jobRunRate );
                }
 
+               $runJobsLogger = MWLoggerFactory::getInstance( 'runJobs' );
+
                if ( !$this->config->get( 'RunJobsAsync' ) ) {
                        // Fall back to running the job here while the user waits
-                       $runner = new JobRunner();
+                       $runner = new JobRunner( $runJobsLogger );
                        $runner->run( array( 'maxJobs'  => $n ) );
                        return;
                }
@@ -643,9 +666,9 @@ class MediaWiki {
                );
                wfRestoreWarnings();
                if ( !$sock ) {
-                       wfDebugLog( 'runJobs', "Failed to start cron API (socket error $errno): $errstr\n" );
+                       $runJobsLogger->error( "Failed to start cron API (socket error $errno): $errstr" );
                        // Fall back to running the job here while the user waits
-                       $runner = new JobRunner();
+                       $runner = new JobRunner( $runJobsLogger );
                        $runner->run( array( 'maxJobs'  => $n ) );
                        return;
                }
@@ -653,19 +676,19 @@ class MediaWiki {
                $url = wfAppendQuery( wfScript( 'index' ), $query );
                $req = "POST $url HTTP/1.1\r\nHost: {$info['host']}\r\nConnection: Close\r\nContent-Length: 0\r\n\r\n";
 
-               wfDebugLog( 'runJobs', "Running $n job(s) via '$url'\n" );
+               $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 );
                $bytes = fwrite( $sock, $req );
                if ( $bytes !== strlen( $req ) ) {
-                       wfDebugLog( 'runJobs', "Failed to start cron API (socket write error)\n" );
+                       $runJobsLogger->error( "Failed to start cron API (socket write error)" );
                } else {
                        // Do not wait for the response (the script should handle client aborts).
                        // Make sure that we don't close before that script reaches ignore_user_abort().
                        $status = fgets( $sock );
                        if ( !preg_match( '#^HTTP/\d\.\d 202 #', $status ) ) {
-                               wfDebugLog( 'runJobs', "Failed to start cron API: received '$status'\n" );
+                               $runJobsLogger->error( "Failed to start cron API: received '$status'" );
                        }
                }
                fclose( $sock );