reverted: --- b/core/modules/taxonomy/taxonomy.install +++ a/core/modules/taxonomy/taxonomy.install @@ -8,7 +8,6 @@ use Drupal\Core\Entity\Sql\SqlEntityStorageInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Site\Settings; -use Drupal\node\NodeInterface; /** * Convert the custom taxonomy term hierarchy storage to a default storage. @@ -249,49 +248,3 @@ } $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); } - -/** - * Add unpublished nodes to the taxonomy index table. - */ -function taxonomy_update_8703(&$sandbox) { - $database = \Drupal::database(); - - if (!isset($sandbox['total'])) { - // Initialize state for future calls. - $sandbox['last'] = 0; - $sandbox['count'] = 0; - - $query = $database->select('node_field_data', 'n') - ->condition('n.status', NodeInterface::NOT_PUBLISHED); - $sandbox['total'] = $query->countQuery()->execute()->fetchField(); - } - - if ($sandbox['total']) { - // Operate on every unpublished node, in batches. - $batch_size = 100; - $query = $database->select('node_field_data', 'n'); - $query - ->fields('n', ['nid']) - ->condition('n.nid', $sandbox['last'], '>') - ->condition('n.status', NodeInterface::NOT_PUBLISHED) - ->orderBy('n.nid', 'ASC') - ->range(0, $batch_size); - $nids = $query->execute()->fetchCol(); - $node_storage = \Drupal::entityTypeManager()->getStorage('node'); - // Build the taxonomy index for each node. - foreach ($node_storage->loadMultiple($nids) as $node) { - // Delete node index to avoid integrity constraint violation errors. - taxonomy_delete_node_index($node); - taxonomy_build_node_index($node); - $sandbox['last'] = $node->id(); - } - $sandbox['count'] += $batch_size; - } - // Finish after all the unpublished nodes have been processed. - if ($sandbox['count'] < $sandbox['total']) { - $sandbox['#finished'] = FALSE; - } - else { - $sandbox['#finished'] = TRUE; - } -} only in patch2: unchanged: --- a/core/modules/taxonomy/taxonomy.post_update.php +++ b/core/modules/taxonomy/taxonomy.post_update.php @@ -10,6 +10,8 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\views\ViewExecutable; +use Drupal\Core\Site\Settings; +use Drupal\node\NodeInterface; /** * Clear caches due to updated taxonomy entity views data. @@ -253,3 +255,50 @@ function taxonomy_post_update_configure_status_field_widget(&$sandbox = NULL) { return FALSE; }); } + +/** + * Add unpublished nodes to the taxonomy index table. + */ +function taxonomy_post_update_add_unpublished_nodes_to_taxonomy_index(&$sandbox) { + $database = \Drupal::database(); + + if (!isset($sandbox['total'])) { + // Initialize state for future calls. + $sandbox['last'] = 0; + $sandbox['count'] = 0; + + $query = $database->select('node_field_data', 'n') + ->condition('n.status', NodeInterface::NOT_PUBLISHED); + $sandbox['total'] = $query->countQuery()->execute()->fetchField(); + } + + if ($sandbox['total']) { + // Operate on every unpublished node, in batches. + $batch_size = Settings::get('entity_update_batch_size', 100); + $query = $database->select('node_field_data', 'n'); + $query + ->fields('n', ['nid']) + ->condition('n.nid', $sandbox['last'], '>') + ->condition('n.status', NodeInterface::NOT_PUBLISHED) + ->orderBy('n.nid', 'ASC') + ->range(0, $batch_size); + $nids = $query->execute()->fetchCol(); + // Build the taxonomy index for each node. + foreach ($nids as $nid) { + $node = new stdClass(); + $node->id = $nid; + // Delete node index to avoid integrity constraint violation errors. + taxonomy_delete_node_index($node); + taxonomy_build_node_index($node); + $sandbox['last'] = $node->id; + } + $sandbox['count'] += $batch_size; + } + // Finish after all the unpublished nodes have been processed. + if ($sandbox['count'] < $sandbox['total']) { + $sandbox['#finished'] = FALSE; + } + else { + $sandbox['#finished'] = TRUE; + } +}