Merge "Title::getTalkPage(): Restore behavior of interwiki-prefixed & fragment-only...
[lhc/web/wiklou.git] / includes / jobqueue / utils / PurgeJobUtils.php
index 5d8a6cf..1e40eb4 100644 (file)
@@ -36,11 +36,12 @@ class PurgeJobUtils {
                if ( $dbkeys === [] ) {
                        return;
                }
+               $fname = __METHOD__;
 
                DeferredUpdates::addUpdate( new AutoCommitUpdate(
                        $dbw,
                        __METHOD__,
-                       function () use ( $dbw, $namespace, $dbkeys ) {
+                       function () use ( $dbw, $namespace, $dbkeys, $fname ) {
                                $services = MediaWikiServices::getInstance();
                                $lbFactory = $services->getDBLoadBalancerFactory();
                                // Determine which pages need to be updated.
@@ -55,7 +56,7 @@ class PurgeJobUtils {
                                                'page_title' => $dbkeys,
                                                'page_touched < ' . $dbw->addQuotes( $now )
                                        ],
-                                       __METHOD__
+                                       $fname
                                );
 
                                if ( !$ids ) {
@@ -63,8 +64,9 @@ class PurgeJobUtils {
                                }
 
                                $batchSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' );
-                               $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
-                               foreach ( array_chunk( $ids, $batchSize ) as $idBatch ) {
+                               $ticket = $lbFactory->getEmptyTransactionTicket( $fname );
+                               $idBatches = array_chunk( $ids, $batchSize );
+                               foreach ( $idBatches as $idBatch ) {
                                        $dbw->update(
                                                'page',
                                                [ 'page_touched' => $now ],
@@ -72,9 +74,11 @@ class PurgeJobUtils {
                                                        'page_id' => $idBatch,
                                                        'page_touched < ' . $dbw->addQuotes( $now ) // handle races
                                                ],
-                                               __METHOD__
+                                               $fname
                                        );
-                                       $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
+                                       if ( count( $idBatches ) > 1 ) {
+                                               $lbFactory->commitAndWaitForReplication( $fname, $ticket );
+                                       }
                                }
                        }
                ) );