From 32b62ebd4b9e0c1bb77f252fc53312c2fbaa8de9 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 6 Dec 2012 19:30:25 -0800 Subject: [PATCH] [JobQueue] Added a sanity check to catch ack() breakage. * Also make sure the "id" field is set even if broken subclasses do not set it as the base class does. Change-Id: I2f617187e225df6c1b02b4062c835cd6581c5d99 --- includes/job/JobQueueDB.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php index cf6f1b97cf..ef5c346f3d 100644 --- a/includes/job/JobQueueDB.php +++ b/includes/job/JobQueueDB.php @@ -174,6 +174,7 @@ class JobQueueDB extends JobQueue { } $job = Job::factory( $row->job_cmd, $title, self::extractBlob( $row->job_params ), $row->job_id ); + $job->id = $row->job_id; // XXX: work around broken subclasses // Flag this job as an old duplicate based on its "root" job... if ( $this->isRootJobOldDuplicate( $job ) ) { $job = DuplicateJob::newFromJob( $job ); // convert to a no-op @@ -344,6 +345,10 @@ class JobQueueDB extends JobQueue { * @return Job|bool */ protected function doAck( Job $job ) { + if ( !$job->getId() ) { + throw new MWException( "Job of type '{$job->getType()}' has no ID." ); + } + $dbw = $this->getMasterDB(); $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction -- 2.20.1