diff --git a/feeds.module b/feeds.module index 4a338da..7270ae5 100644 --- a/feeds.module +++ b/feeds.module @@ -78,9 +78,6 @@ function feeds_cron_job_scheduler_info() { $info['feeds_source_import'] = array( 'queue name' => 'feeds_source_import', ); - $info['feeds_source_clear'] = array( - 'queue name' => 'feeds_source_clear', - ); $info['feeds_source_expire'] = array( 'queue name' => 'feeds_source_expire', ); diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc index bb03d0e..4f5ea9d 100644 --- a/includes/FeedsSource.inc +++ b/includes/FeedsSource.inc @@ -254,7 +254,8 @@ class FeedsSource extends FeedsConfigurable { public function startImport() { $config = $this->importer->getConfig(); if ($config['process_in_background']) { - $this->startBackgroundJob('import'); + $this->import(); + $this->scheduleImport(); } else { $this->startBatchAPIJob(t('Importing'), 'import'); @@ -276,7 +277,8 @@ class FeedsSource extends FeedsConfigurable { public function startClear() { $config = $this->importer->getConfig(); if ($config['process_in_background']) { - $this->startBackgroundJob('clear'); + $this->clear(); + $this->scheduleClear(); } else { $this->startBatchAPIJob(t('Deleting'), 'clear'); @@ -349,16 +351,13 @@ class FeedsSource extends FeedsConfigurable { $job = array( 'type' => $this->id, 'id' => $this->feed_nid, - 'period' => 0, - 'periodic' => TRUE, ); - // Remove job if batch is complete. - if ($this->progressClearing() === FEEDS_BATCH_COMPLETE) { - JobScheduler::get('feeds_source_clear')->remove($job); - } - // Schedule as soon as possible if batch is not complete. - else { - JobScheduler::get('feeds_source_clear')->set($job); + + if ($this->progressClearing() !== FEEDS_BATCH_COMPLETE) { + // Feed is not fully cleared yet, so we put this job back in the queue + // immediately for further processing. + $queue = DrupalQueue::get('feeds_source_clear'); + $queue->createItem($job); } } @@ -789,36 +788,6 @@ class FeedsSource extends FeedsConfigurable { } /** - * Background job helper. Starts a background job using Job Scheduler. - * - * Execute the first batch chunk of a background job on the current page load, - * moves the rest of the job processing to a cron powered background job. - * - * Executing the first batch chunk is important, otherwise, when a user - * submits a source for import or clearing, we will leave her without any - * visual indicators of an ongoing job. - * - * @see FeedsSource::startImport(). - * @see FeedsSource::startClear(). - * - * @param $method - * Method to execute on importer; one of 'import' or 'clear'. - * - * @throws Exception $e - */ - protected function startBackgroundJob($method) { - if (FEEDS_BATCH_COMPLETE != $this->$method()) { - $job = array( - 'type' => $this->id, - 'id' => $this->feed_nid, - 'period' => 0, - 'periodic' => FALSE, - ); - JobScheduler::get("feeds_source_{$method}")->set($job); - } - } - - /** * Batch API helper. Starts a Batch API job. * * @see FeedsSource::startImport().