Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
[lhc/web/wiklou.git] / includes / MediaWiki.php
index b3abe7c..1642377 100644 (file)
@@ -636,9 +636,11 @@ class MediaWiki {
 
                if ( $cpIndex > 0 ) {
                        if ( $allowHeaders ) {
-                               $expires = time() + ChronologyProtector::POSITION_TTL;
+                               $now = time();
+                               $expires = $now + ChronologyProtector::POSITION_COOKIE_TTL;
                                $options = [ 'prefix' => '' ];
-                               $request->response()->setCookie( 'cpPosIndex', $cpIndex, $expires, $options );
+                               $value = LBFactory::makeCookieValueFromCPIndex( $cpIndex, $now ); // T190082
+                               $request->response()->setCookie( 'cpPosIndex', $value, $expires, $options );
                        }
 
                        if ( $strategy === 'cookie+url' ) {
@@ -758,7 +760,7 @@ class MediaWiki {
                $request = $this->context->getRequest();
 
                // Send Ajax requests to the Ajax dispatcher.
-               if ( $this->config->get( 'UseAjax' ) && $request->getVal( 'action' ) === 'ajax' ) {
+               if ( $request->getVal( 'action' ) === 'ajax' ) {
                        // Set a dummy title, because $wgTitle == null might break things
                        $title = Title::makeTitle( NS_SPECIAL, 'Badtitle/performing an AJAX call in '
                                . __METHOD__
@@ -937,7 +939,7 @@ class MediaWiki {
                        try {
                                $statsdServer = explode( ':', $config->get( 'StatsdServer' ) );
                                $statsdHost = $statsdServer[0];
-                               $statsdPort = isset( $statsdServer[1] ) ? $statsdServer[1] : 8125;
+                               $statsdPort = $statsdServer[1] ?? 8125;
                                $statsdSender = new SocketSender( $statsdHost, $statsdPort );
                                $statsdClient = new SamplingStatsdClient( $statsdSender, true, false );
                                $statsdClient->setSamplingRates( $config->get( 'StatsdSamplingRates' ) );
@@ -998,8 +1000,14 @@ class MediaWiki {
         * @param LoggerInterface $runJobsLogger
         */
        private function triggerSyncJobs( $n, LoggerInterface $runJobsLogger ) {
-               $runner = new JobRunner( $runJobsLogger );
-               $runner->run( [ 'maxJobs' => $n ] );
+               $trxProfiler = Profiler::instance()->getTransactionProfiler();
+               $old = $trxProfiler->setSilenced( true );
+               try {
+                       $runner = new JobRunner( $runJobsLogger );
+                       $runner->run( [ 'maxJobs' => $n ] );
+               } finally {
+                       $trxProfiler->setSilenced( $old );
+               }
        }
 
        /**