Merge "Made SwiftFileBackend::loadObjectListing() populate stat entries in reverse...
[lhc/web/wiklou.git] / includes / job / JobQueueDB.php
index 6f4f6d9..56da4f3 100644 (file)
@@ -231,7 +231,7 @@ class JobQueueDB extends JobQueue {
                                        $method
                                );
                                foreach ( $res as $row ) {
-                                       wfDebug( "Job with hash '{$row->job_sha1}' is a duplicate." );
+                                       wfDebug( "Job with hash '{$row->job_sha1}' is a duplicate.\n" );
                                        unset( $rowSet[$row->job_sha1] ); // already enqueued
                                }
                        }
@@ -270,6 +270,11 @@ class JobQueueDB extends JobQueue {
 
                list( $dbw, $scope ) = $this->getMasterDB();
                $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
+               $autoTrx = $dbw->getFlag( DBO_TRX ); // get current setting
+               $dbw->clearFlag( DBO_TRX ); // make each query its own transaction
+               $scopedReset = new ScopedCallback( function() use ( $dbw, $autoTrx ) {
+                       $dbw->setFlag( $autoTrx ? DBO_TRX : 0 ); // restore old setting
+               } );
 
                $uuid = wfRandomString( 32 ); // pop attempt
                $job = false; // job popped off
@@ -457,6 +462,11 @@ class JobQueueDB extends JobQueue {
 
                list( $dbw, $scope ) = $this->getMasterDB();
                $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
+               $autoTrx = $dbw->getFlag( DBO_TRX ); // get current setting
+               $dbw->clearFlag( DBO_TRX ); // make each query its own transaction
+               $scopedReset = new ScopedCallback( function() use ( $dbw, $autoTrx ) {
+                       $dbw->setFlag( $autoTrx ? DBO_TRX : 0 ); // restore old setting
+               } );
 
                // Delete a row with a single DELETE without holding row locks over RTTs...
                $dbw->delete( 'job',
@@ -499,6 +509,17 @@ class JobQueueDB extends JobQueue {
                return true;
        }
 
+       /**
+        * @see JobQueue::doDelete()
+        * @return bool
+        */
+       protected function doDelete() {
+               list( $dbw, $scope ) = $this->getMasterDB();
+
+               $dbw->delete( 'job', array( 'job_cmd' => $this->type ) );
+               return true;
+       }
+
        /**
         * @see JobQueue::doWaitForBackups()
         * @return void