Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

Provides a Drupal queue you can use to process a bunch of operations in an asynchronous way.

For example if you have 1 million items you want to query and do operations on, in an update hook, it would be better to do them async.

Just use this queue, and pass it a callback and some arguments, and you are good to go.

Example

/**
 * Update all of the nodes on the site.
 */
function mymodule_update_8001() {
  $nids = somehow_get_an_array_of_one_million_nids();
  $queue = \Drupal::queue('update_worker');
  foreach ($nids as $nid) {
    $queue->createItem([
      'callback' => 'mymodule_update_node',
      'arguments' => [
        $nid,
      ],
    ]);
  }
}

And then you probably have something like this defined in your module:

/**
 * Helper function to update a node.
 */
function mymodule_update_node($nid) {
  $node = Node::load($nid);
  $node->set('my_field', 'some_new_value');
  $node->save();
}

Now, instead of your site being offline while the update hook is running, you can just process all of the nodes asynchronously.

Of course, you could combine this into one more abstraction layer, by using the update hook to create for example 1000 queue items that would in turn each queue 1000 nids, meaning even less time spent running database updates. But that would be an exercise left to the reader.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jun 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Slowing

Releases

Version Type Core Release date
2.0.2 Stable Mar 25, 2024
2.0.1 Stable Jun 14, 2023