summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-01-31 15:27:33 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-01-31 15:27:33 -0500
commit5be1de31ae1664917cd36141d743b5e8fd95cac6 (patch)
treefd35b8c05a4bdf6feee0bf38081dfe8b298b58f1 /modules/taxonomy
parent7b794acfa0948b97b6c946bf4ebc475341985527 (diff)
downloadbrdo-5be1de31ae1664917cd36141d743b5e8fd95cac6.tar.gz
brdo-5be1de31ae1664917cd36141d743b5e8fd95cac6.tar.bz2
Issue #2174551 by David_Rothstein, mikeytown2, hswong3i: Taxonomy_update_7011 runs out of memory.
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.install25
1 files changed, 23 insertions, 2 deletions
diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install
index e3603e1ac..ebd0084a5 100644
--- a/modules/taxonomy/taxonomy.install
+++ b/modules/taxonomy/taxonomy.install
@@ -903,13 +903,34 @@ 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();
+function taxonomy_update_7011(&$sandbox) {
+ // Initialize information needed by the batch update system.
+ if (!isset($sandbox['progress'])) {
+ $sandbox['progress'] = 0;
+ $sandbox['max'] = db_query('SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {taxonomy_index} t ON n.nid = t.nid WHERE n.status = :status', array(':status' => NODE_NOT_PUBLISHED))->fetchField();
+ // If there's no data, don't bother with the extra work.
+ if (empty($sandbox['max'])) {
+ return;
+ }
+ }
+
+ // Process records in groups of 5000.
+ $limit = 5000;
+ $nids = db_query_range('SELECT DISTINCT n.nid FROM {node} n INNER JOIN {taxonomy_index} t ON n.nid = t.nid WHERE n.status = :status', 0, $limit, array(':status' => NODE_NOT_PUBLISHED))->fetchCol();
if (!empty($nids)) {
db_delete('taxonomy_index')
->condition('nid', $nids)
->execute();
}
+
+ // Update our progress information for the batch update.
+ $sandbox['progress'] += $limit;
+
+ // Indicate our current progress to the batch update system, if the update is
+ // not yet complete.
+ if ($sandbox['progress'] < $sandbox['max']) {
+ $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
+ }
}
/**