Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Set value for field_seccion_general to the nodes that not have this field set.
- */
- function incae_custom_functions_update_7003(&$sandbox) {
- if (!isset($sandbox['progress'])) {
- $entities = incae_custom_functions_get_unset_field_seccion_genenal_entities('node');
- $sandbox['max'] = count($entities) - 1;
- $sandbox['limit'] = 100;
- $sandbox['entities'] = array_values(node_load_multiple($entities));
- $sandbox['progress'] = 0;
- }
- watchdog('sandbox p', serialize($sandbox['progress']));
- $chunk = array_slice($sandbox['entities'], $sandbox['progress'], $sandbox['limit']);
- if (count($chunk)) {
- foreach ($chunk as $key => $entity) {
- $wrapper = entity_metadata_wrapper('node', $entity);
- $wrapper->field_seccion_general = array('masters');
- $wrapper->save();
- $sandbox['progress'] = $key;
- if ($key == $sandbox['max']) {
- $sandbox['#finish'] = 1;
- }
- else {
- $sandbox['#finish'] = -1;
- }
- }
- }
- if ($sandbox['#finish'] === TRUE) {
- return 'the last procced node was ' . $sandbox['progress'];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement