For thousands of nodes a fail-safe batch process we will build. We developed batch process for running cron services. The operations we made for sending notification to the subscribers, deleting unapproved content, Search and Replace on the csv file being uploaded to create node are a fews instances to mention.
The main concern is ‘How we will make it fail safe’?
We will provide you an interface that will allow you to run the ‘SR’ for a specified number of nodes. We will keep a log of successful operations. We will display those on the interface to keep track of the successful operation.
You already have made the the ‘Search and Replacement’ code. We will use it as the operation callback.
The module will be a small module. The BATCH API need to set the function that will execute on each batch.
We will build this operations in an operation array.
Each operation is an array consisting of
- The function to call .
- An array of arguments to that function.
Then we set the batch process to that should run.
[CODE ]
$operations = array();
for ($i = 0; $i < $num_operations; $i++) {
$operations[] = array(
'batch_SR', // the functions
array( // arguments to the functions
$nid,
t('(Operation @operation)', array('@operation' => $i)),
),
);
}
$batch = array(
'operations' => $operations,
'finished' => 'batch_SR_finished',
);
[CODE ]