if (!
isset($context['sandbox'
]['progress'
])) { $context['sandbox'
]['progress'
] = 0;
$context['sandbox'
]['current_node'
] = 0;
$context['sandbox'
]['max'
] =
$database->
query('SELECT COUNT(DISTINCT [nid]) FROM {node}'
)->
fetchField();
} // For this example, we decide that we can safely process
// 5 nodes at a time without a timeout.
$limit = 5;
// With each pass through the callback, retrieve the next group of nids.
$result =
$database->
queryRange("SELECT [nid] FROM {node} WHERE [nid] > :nid ORDER BY [nid] ASC", 0,
$limit,
[':nid' =>
$context['sandbox'
]['current_node'
]]);
foreach ($result as $row) { // Here we actually perform our processing on the current node.
$node_storage->
resetCache([$row['nid'
]]);
$node =
$node_storage->
load($row['nid'
]);
$node->value1 =
$options1;
$node->value2 =
$options2;
node_save($node);
// Store some result for post-processing in the finished callback.
$context['results'
][] =
$node->title;