Using clean install of 6.0-beta3, create a blog entry and previewing it reveals the following error:

warning: Invalid argument supplied for foreach() in /var/www/localhost/htdocs/opt_drupal/modules/taxonomy/taxonomy.module on line 516.

Here is a patch that simple checks that the taxonomy array exists before foreach-ing it:

Index: taxonomy.module
===================================================================
--- taxonomy.module	(revision 1066)
+++ taxonomy.module	(working copy)
@@ -513,25 +513,27 @@
  */
 function taxonomy_preview_terms($node) {
   $taxonomy = array();
-  foreach ($node->taxonomy as $key => $term) {
-    unset($node->taxonomy[$key]);
-    // A 'Multiple select' and a 'Free tagging' field returns an array.
-    if (is_array($term)) {
-      foreach ($term as $tid) {
-        if ($key == 'tags') {
-          // Free tagging; the values will be saved for later as strings
-    // instead of objects to fill the form again.
-          $taxonomy['tags'] = $term;
+  if (is_array($node->taxonomy)) { 
+    foreach ($node->taxonomy as $key => $term) {
+      unset($node->taxonomy[$key]);
+      // A 'Multiple select' and a 'Free tagging' field returns an array.
+      if (is_array($term)) {
+        foreach ($term as $tid) {
+          if ($key == 'tags') {
+            // Free tagging; the values will be saved for later as strings
+      // instead of objects to fill the form again.
+            $taxonomy['tags'] = $term;
+          }
+          else {
+            $taxonomy[$tid] = taxonomy_get_term($tid);
+          }
         }
-        else {
-          $taxonomy[$tid] = taxonomy_get_term($tid);
-        }
       }
+      // A 'Single select' field returns the term id.
+      elseif ($term) {
+        $taxonomy[$term] = taxonomy_get_term($term);
+      }
     }
-    // A 'Single select' field returns the term id.
-    elseif ($term) {
-      $taxonomy[$term] = taxonomy_get_term($term);
-    }
   }
   return $taxonomy;
 }
CommentFileSizeAuthor
#1 taxonomy-absense.patch1.61 KBrcorsaro

Comments

rcorsaro’s picture

StatusFileSize
new1.61 KB
catch’s picture

Status: Active » Needs review
catch’s picture

Version: 6.0-beta3 » 6.x-dev
Status: Needs review » Fixed

I can't reproduce this, and the patch doesn't apply with the latest -dev snapshot so marking as fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.