Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291393

NodeNG conversion follow-up: Only first forum tid is saved into {forum_index}

$
0
0

Follow-up from #1818556-207: Convert nodes to the new Entity Field API.

+++ b/core/modules/forum/forum.module

function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) {
   if ($entity->entityType() == 'node'&& $entity->status && _forum_node_check_node_type($entity)) {
     $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
-    foreach ($entity->taxonomy_forums as $language) {
-      foreach ($language as $item) {
-        $query->values(array(
-          'nid' => $entity->nid,
-          'title' => $entity->title,
-          'tid' => $item['tid'],
-          'sticky' => $entity->sticky,
-          'created' => $entity->created,
-          'comment_count' => 0,
-          'last_comment_timestamp' => $entity->created,
-        ));
-      }
+    foreach ($entity->getTranslationLanguages() as $langcode => $language) {
+      $translation = $entity->getTranslation($langcode, FALSE);
+      $query->values(array(
+        'nid' => $entity->id(),
+        'title' => $translation->title->value,
+        'tid' => $translation->taxonomy_forums->tid,
+        'sticky' => $entity->sticky,
+        'created' => $entity->created,
+        'comment_count' => 0,
+        'last_comment_timestamp' => $entity->created,
+      ));
     }
     $query->execute();
   }

The NG + language/translation changes are fine, but:

How and why was $entity->taxonomy_forums->tid suddenly turned into a single-valued item?

The new logic inserts a single value per language.

The old logic inserted multiple values for each language.


Viewing all articles
Browse latest Browse all 291393

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>