Drupal - How can I quickly re-save all the nodes on my site (to trigger a rule that activates on content update)?

VBO has an "Execute PHP code" action. Run it, and input "node_save($entity);" (without the quotes) in the textbox. That will do the trick, while handling the timeouts for you.


I don't know about rules or VBO but you could use a short code snippet to get the same result:

$nids = db_query('SELECT nid FROM {node}')->fetchCol();
foreach (node_load_multiple($nids) as $node) {
  node_save($node);
}

If you've got a lot of nodes that might take a bit of time so if your server allows it it'd be a good idea to extend the time limit at the start of that code, perhaps to unlimited if this is a one off:

set_time_limit(0);

You can use the node_mass_update() function:

module_load_include('inc', 'node', 'node.admin');
$nids = db_query('SELECT nid FROM {node}')->fetchCol();
node_mass_update($nids, array());

It's very good as you don't need to care about the time limit. Batch process for nodes update will start automatically if there are more than 10 nodes.

Tags:

Rules