I am working on this issue in the Feeds issue queue: https://www.drupal.org/node/2341407
I am trying to make the updates to the importers run in batches. I can't figure out why this won't run in multiple batches when there are multiple importers. What happens is instead of seeing a progress bar reload a few times when running update.php, it loads once and processes all importers in a single batch.
The code works well except for batching. Below is the code. Thanks in advance!
<?php /** * Fix importer mappings for file and image fields to use :uri convention. */ function feeds_update_7210(&$sandbox) { // If this is the first pass through this update function then set some variables. if (!isset($sandbox['total'])) { // Load all importers. $importers = feeds_importer_load_all(TRUE); $sandbox['total'] = count($importers); $sandbox['current'] = 0; } foreach ($importers as $importer) { $processor = $importer->processor; $config = $processor->getConfig(); foreach ($config['mappings'] as $id=>$mapping) { // Act on mappings that do not contain a colon. if (!strpos($mapping['target'], ':')) { // Get field data. Check if $info is empty to weed out non-field mappings like temporary targets. $info = field_info_field($mapping['target']); if (!empty($info)) { // Act on file or image fields. if (in_array($info['type'], array('file', 'image'))) { // Add ':uri' to fix the mapping. $config['mappings'][$id]['target'] = $mapping['target'] . ':uri'; } } } } // Add the updated config and save the importer. $processor->addConfig(array('mappings' => $config['mappings'])); $importer->save(); drupal_set_message(t('@importer fields have been updated.', array('@importer' => $importer->id))); $sandbox['current']++; } // Set the value for finished. If current == total then finished will be 1, signifying we are done. $sandbox['#finished'] = ($sandbox['current'] / $sandbox['total']); if ($sandbox['#finished'] === 1) { drupal_set_message(t('@importers importers processed.', array('@importers' => $sandbox['total']))); } }