From 0a4102a19ce52aca938b362e041ec68e23dd061b Mon Sep 17 00:00:00 2001 From: Wong Hoi Sing Edison Date: Fri, 17 Jan 2014 11:44:03 +0800 Subject: [PATCH] Issue #2174551 by hswong3i: taxonomy_update_7011 runs out of memory. --- modules/taxonomy/taxonomy.install | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install index e3603e1..b3d7e4d 100644 --- a/modules/taxonomy/taxonomy.install +++ b/modules/taxonomy/taxonomy.install @@ -904,10 +904,17 @@ function taxonomy_update_7010() { * Drop unpublished nodes from the index. */ function taxonomy_update_7011() { - $nids = db_query('SELECT nid from {node} WHERE status = :status', array(':status' => NODE_NOT_PUBLISHED))->fetchCol(); - if (!empty($nids)) { + $nids = db_query('SELECT nid from {node} WHERE status = :status', array( + ':status' => NODE_NOT_PUBLISHED + ))->fetchCol(); + + // Prevent running out of memory, by execute 50 nids each time. + // @see https://drupal.org/node/2174551 + while (!empty($nids)) { + $slice = array_slice($nids, 0, 50); + $nids = array_slice($nids, 50); db_delete('taxonomy_index') - ->condition('nid', $nids) + ->condition('nid', $slice) ->execute(); } } -- 1.7.9.5