Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By tim.plunkett on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Description:
Implementations of hook_queue_info() are replaced with an annotated class to reside in \Drupal\*\Plugin\QueueWorker, annotated with Drupal\Core\Annotation\QueueWorker, implementing the interface of Drupal\Core\Queue\QueueWorkerInterface
Drupal 7:
function aggregator_cron_queue_info() {
$queues['aggregator_feeds'] = array(
'title' => t('Aggregator refresh'),
'worker callback' => 'aggregator_refresh',
'cron' => array(
'time' => 60,
),
);
return $queues;
}
Previously in Drupal 8, aggregator_refresh($feed) was replaced by a direct call to $feed->refreshItems(), and hook_cron_queue_info()/hook_cron_queue_info_alter() were renamed hook_queue_info()/hook_queue_info_alter().
Drupal 8:
/**
* @file
* Contains \Drupal\aggregator\Plugin\QueueWorker\AggregatorRefresh.
*/
namespace Drupal\aggregator\Plugin\QueueWorker;
use Drupal\aggregator\FeedInterface;
use Drupal\Core\Queue\QueueWorkerBase;
/**
* @QueueWorker(
* id = "aggregator_feeds",
* title = @Translation("Aggregator refresh"),
* cron = {"time" = 60}
* )
*/
class AggregatorRefresh extends QueueWorkerBase {
/**
* {@inheritdoc}
*/
public function processItem($data) {
if ($data instanceof FeedInterface) {
$data->refreshItems();
}
}
}
Impacts:
Module developers