🇮🇳India nishat ahmad
I encountered issues when I updated the Drupal core from version 10.1.8 to 10.2.6.
🇮🇳India nishat ahmad
Fatal error: Cannot redeclare field_form_field_config_edit_form_entity_builder() (previously declared in /var/www/html/docroot/core/modules/field/field.module:470) in /var/www/html/docroot/core/modules/field/field.module on line 518
🇮🇳India nishat ahmad
Nishat Ahmad → created an issue.
🇮🇳India nishat ahmad
@d.steindl if you have time do it dynamic.
🇮🇳India nishat ahmad
I changed the patch according to D10 and have tested it, but for Draft mode, it's not working.
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 5f011c6..0a52f59 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -179,10 +179,9 @@ function taxonomy_build_node_index($node) {
return;
}
- $status = $node->isPublished();
+ //$status = $node->isPublished();
$sticky = (int) $node->isSticky();
- // We only maintain the taxonomy index for published nodes.
- if ($status && $node->isDefaultRevision()) {
+ if ($node->isDefaultRevision()) {
// Collect a unique list of all the term IDs from all node fields.
$tid_all = [];
$entity_reference_class = 'Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem';
@@ -192,11 +191,19 @@ function taxonomy_build_node_index($node) {
$is_entity_reference_class = ($class === $entity_reference_class) || is_subclass_of($class, $entity_reference_class);
if ($is_entity_reference_class && $field->getSetting('target_type') == 'taxonomy_term') {
foreach ($node->getTranslationLanguages() as $language) {
- foreach ($node->getTranslation($language->getId())->$field_name as $item) {
- if (!$item->isEmpty()) {
- $tid_all[$item->target_id] = $item->target_id;
+ // foreach ($node->getTranslation($language->getId())->$field_name as $item) {
+ // if (!$item->isEmpty()) {
+ // $tid_all[$item->target_id] = $item->target_id;
+ /** @var \Drupal\node\NodeInterface $translation */
+ $translation = $node->getTranslation($language->getId());
+ // only maintain the taxonomy_index table for published node translations
+ if($translation->isPublished()) {
+ foreach($translation->$field_name as $item) {
+ if(!$item->isEmpty()) {
+ $tid_all[$item->target_id] = $item->target_id;
+ }
+ }
}
- }
}
}
}
@@ -204,8 +211,13 @@ function taxonomy_build_node_index($node) {
if (!empty($tid_all)) {
$connection = \Drupal::database();
foreach ($tid_all as $tid) {
+ // TODO: the status column makes no sense in the taxonomy_index table,
+ // since only published node translations get indexed. That means, that
+ // all indexed nids are published in at least one translation language.
+ // --> hardcode the 'status' column to 1
$connection->merge('taxonomy_index')
- ->key(['nid' => $node->id(), 'tid' => $tid, 'status' => $node->isPublished()])
+ //->key(['nid' => $node->id(), 'tid' => $tid, 'status' => $node->isPublished()])
+ ->key(['nid' => $node->id(), 'tid' => $tid, 'status' => 1])
->fields(['sticky' => $sticky, 'created' => $node->getCreatedTime()])
->execute();
}