- Issue created by @davidgould
- 🇮🇹Italy apaderno Brescia, 🇮🇹
The correct code that uses
batch_set()
is similar to the following one. (It has been taken fromnode_mass_update()
.)$batch = array( 'operations' => array(array('_node_mass_update_batch_process', array($nodes, $updates))), 'finished' => '_node_mass_update_batch_finished', 'title' => t('Processing'), // We use a single multi-pass operation, so the default // 'Remaining x of y operations' message will be confusing here. 'progress_message' => '', 'error_message' => t('The update has encountered an error.'), // The operations do not live in the .module file, so we need to // tell the batch engine which file to load before calling them. 'file' => drupal_get_path('module', 'node') . '/node.admin.inc', ); batch_set($batch);
Notice how the
'operations'
array index is defined, in particular thearray($nodes, $updates)
part.
If you replace that witharray($nodes, 'updates' => $updates)
, you will get an error message described in the issue summary.batch_set()
describes'operations'
as:operations: (required) Array of operations to be performed, where each item is an array consisting of the name of an implementation of
callback_batch_operation()
and an array of parameter.The example shown does not use an associate array, but the documentation does not say an associative array must not be used. That should be probably made explicit.