Computed Field Tools (Drupal 7) Batch running
Computed Field Tools (Drupal 7)

The problem

The Computed Field module only updates its computed values on saves or on load (if no computed value is computed yet). This is not optimal when using computed values in lists etc., or if you should wish to change the logic in the computed field.

The solution

If you wish to avoid re-saving all the entities/nodes using the computing field, you can use this tool to re-compute all the values again.

The computed field tools module offers a way to re-compute the computed fields of existing entities/nodes. It does so through the Batch API.

When the batch is running it does not save the entire entity/node, but it only saves the computed field. This make it a fast way of updating the content.

Features

  • Fast processing of all computed fields.
  • Select specific computed_field to process.
  • Select content types to process for selected computed field.
  • It processes ALL entities/nodes. Also the ones with no value computed yet.
  • Drupal 6 supported content: nodes.
  • Drupal 7 supported entity types: nodes, users, terms and other entity types, that follow either the same basic structure as user or node, which should be most others?
  • Since we don't do an entity_save() we don't clear the cache on every(!) node processing and no search index updates are triggered, so there is a huge performance advantage here on high traffic sites over the VBO way.

Entity save vs. Entity re-compute

Please note that when you re-compute the entities (nodes etc.), the entity/node is fetched through load function (node_load(), user_load() etc.) which means that the format of some values might defer from when you submit the node through the node edit form. $node->taxonomy does this.
(Drupal 7 seems to be a little more helpfull than Drupal 6 in that the taxonomies look a bit more alike when saving an entity through the edit form and the loaded entity.)

Developing and testing

When editing the computed field code, it might be helpful to (assuming you are using the devel module) do:

  • To spot how the values are formatted when you save the node from a node edit form: do a dpm($entity); / dpm($node); in the computed field code.
  • To spot how the values are formatted when you re-compute the entity/node via computed_field_tools, just do a $node = node_load(); dpm($node); in some other place than the computed field you are working on.

Do NOT do any loading of the of the entity/node itself inside the computed_field you are working on as this might mess up the field cache / content (CCK) cache. This is not a computed_field_tools bug, but is a general Field/CCK issue.

Project information

Releases