I get errors in my messages screen related to primary term:

Notice: Undefined variable: values in primary_term_token_values() (line 281 of .../sites/all/modules/primary_term/primary_term.module).
Notice: Undefined index: type in primary_term_form_alter() (line 93 of .../sites/all/modules/primary_term/primary_term.module).
Notice: Undefined index: #node in primary_term_form_alter() (line 94 of .../sites/all/modules/primary_term/primary_term.module).
Notice: Undefined index: type in primary_term_form_alter() (line 93 of .../sites/all/modules/primary_term/primary_term.module).
Notice: Undefined index: #node in primary_term_form_alter() (line 94 of .../sites/all/modules/primary_term/primary_term.module).

It looks like the $values variable in primary_term_token_values() could use a default initialization outside of the switch. And the primary_term_form_alter() hook could check to see if $form['type'] exists before trying to call upon it.

If it matters, I'm using Drupal Pressflow 6.20.97 ... thanks!

Comments

carn1x’s picture

I only started getting this after upgrading to Drupal 6.22 (from 6.19) or migrating to Pressflow (I performed both changes pretty close together)

Bill Choy’s picture

Title: Undefined errors » 2 FIXES for Undefined $values errors in primary_term_token_values()

Problem seem to be an uninitialized variable ($values) that gets return, if type is not a 'node'.

diff -r 718df7e9c3c5 www/sites/all/modules/contrib/primary_term/primary_term.module
--- a/www/sites/all/modules/contrib/primary_term/primary_term.module Wed Oct 05 12:12:08 2011 -0400
+++ b/www/sites/all/modules/contrib/primary_term/primary_term.module Wed Oct 05 13:21:47 2011 -0400
@@ -260,6 +260,7 @@
}

function primary_term_token_values($type, $object = NULL) {
+ $values = array();
switch ($type) {
case 'node':
$node = $object;

OR you can put in a DEFAULT case in the switch.
@@ -277,6 +278,8 @@
}
}
break;
+ default:
+ $values = array();
}
return $values;
}