Commit bc03813a authored by effulgentsia's avatar effulgentsia

Issue #2997982 by longwave, plach, johns996: Orphan term hierarchy records can...

Issue #2997982 by longwave, plach, johns996: Orphan term hierarchy records can cause taxonomy_update_8502 to enter an infinite loop

(cherry picked from commit 1bffa612)
parent 316b0bfc
......@@ -60,4 +60,8 @@
}
}
// Insert an extra record with no corresponding term.
// See https://www.drupal.org/project/drupal/issues/2997982
$query->values(['tid' => max($tids) + 1, 'parent' => 0]);
$query->execute();
......@@ -32,7 +32,12 @@ function taxonomy_update_8502(&$sandbox) {
$sandbox['tid'] = -1;
$sandbox['delta'] = 0;
$sandbox['limit'] = Settings::get('entity_update_batch_size', 50);
$sandbox['max'] = $database->select('taxonomy_term_hierarchy')
// Count records using a join, as there might be orphans in the hierarchy
// table. See https://www.drupal.org/project/drupal/issues/2997982.
$select = $database->select('taxonomy_term_hierarchy', 'h');
$select->join('taxonomy_term_data', 'd', 'h.tid = d.tid');
$sandbox['max'] = $select
->countQuery()
->execute()
->fetchField();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment