![drupal auto queue drupal auto queue](https://files.speakerdeck.com/presentations/72838e567b3747ec84d161b4d1a57f2d/slide_14.jpg)
These items can then be executed in one place.įor example, lets say that when you insert a node you want several other nodes to be created that act as inner pages. If the module you are writing requires processing several items at once, which might not be from the same function call, then it might make sense to add them to a queue.
![drupal auto queue drupal auto queue](https://slidetodoc.com/presentation_image_h/ec4ea82abd52c7fe5015ec1cf4fb2245/image-39.jpg)
Drupal auto queue how to#
Why Use Queues?īefore getting into how to use and customise queues I thought it made sense to go into a few real world examples of how to use a queue to accomplish certain tasks. The API uses object oriented principles to generate and define queues so the system is fully customisable. These tasks are then retrieved from the queue at a later date and run.
Drupal auto queue update#
The Update module also makes use of the Queues API, which it uses to store tasks for requests to fetch available update data. The aggregator_refresh() function is defined in aggregator_cron_queue_info() and is used to get the new feed information. These items are then retrieved from the queue and executed by calling the aggregator_refresh() function and passing the information contained in the queue data. Each module that wants to include an item in the system cron queue can do so by implementing a hook called hook_cron_queue_info(), which tells cron what function to callback when the queue items are retrieved.įor example, the aggregator module updates feeds using cron by creating queue items containing the feed information with the name aggregator_feeds during it's cron function call. It works by allowing other modules to create queue items during their normal hook_cron() calls, which are then run afterwards. The new cron system in Drupal 7 uses the Queues API heavily. I won't be going into the batch API in this post, but I might cover it in later posts. The Batch API, which allows lots of things to be done at once, is built upon the Queues API and provides some customised queue classes. The Queues API isn't just a part of the codebase of Drupal, it is used internally as part of several different processes. The Drupal 7 Queues API is a few feature of Drupal and provides a first in first out data structure that is used internally by Drupal itself and can be completely customised.