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;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | taxonomy-absense.patch | 1.61 KB | rcorsaro |
Comments
Comment #1
rcorsaro commentedComment #2
catchComment #3
catchI can't reproduce this, and the patch doesn't apply with the latest -dev snapshot so marking as fixed.
Comment #4
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.