[JobQueue] Added a sanity check to catch ack() breakage.
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 7 Dec 2012 03:30:25 +0000 (19:30 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 7 Dec 2012 03:41:02 +0000 (19:41 -0800)
* 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

index cf6f1b9..ef5c346 100644 (file)
@@ -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