Problem/Motivation

The token var module and its interaction with other contrib modules is producing ~50 notices after the cache (token registry) is cleared
(see attached)

Proposed resolution

Change the boolean check on line 37 (commit hash 0b48d7) to an isset check

if (!empty($token_var_selected_variables) && ($token_var_selected_variables[$key . "|" . $var_key ])) {

becomes

if (!empty($token_var_selected_variables) && isset($token_var_selected_variables[$key . "|" . $var_key ])) {

I've checked the latest dev version in the repo, and this issue seems to be unresolved in the latest dev branch.

Comments

Chim’s picture

Double checked by downloading the latest dev, and issue is unresolved.

fix:

diff --git a/site/sites/all/modules/contrib/token_var/token_var.module b/site/sites/all/modules/contrib/token_var/token_var.module
index ccc4b06..d1e9f21 100644
--- a/site/sites/all/modules/contrib/token_var/token_var.module
+++ b/site/sites/all/modules/contrib/token_var/token_var.module
@@ -15,7 +15,7 @@ function token_var_token_info() {
 
   $token_var_selected_variables = variable_get(TOKENIZE_DRUPAL_VARIABLES_OPTIONS, array());
   foreach ($conf as $key => $var) {
-    if ((!is_array($var)) && (!empty($token_var_selected_variables)) && ($token_var_selected_variables[$key])) {
+    if ((!is_array($var)) && (!empty($token_var_selected_variables)) && isset($token_var_selected_variables[$key])) {
       $info['tokens']['variables'][$key] = array(
         'name' => $key,
         'description' => $var,
@@ -23,7 +23,7 @@ function token_var_token_info() {
     }
     elseif (is_array($var) && ($key != TOKENIZE_DRUPAL_VARIABLES_OPTIONS)) {
       foreach ($var as $var_key => $var_val) {
-        if (!empty($token_var_selected_variables) && ($token_var_selected_variables[$key . "|" . $var_key ])) {
+        if (!empty($token_var_selected_variables) && isset($token_var_selected_variables[$key . "|" . $var_key ])) {
           $info['tokens']['variables_array'][$key . "|" . $var_key] = array(
             'name' => $key . "|" . $var_key,
             'description' => $var_val,
piyuesh23’s picture

Hi chim,

I have updated the dev version of the module with the required changes. The boolean check should be invoked after the isset check. SO both isset and the boolean check should stay in the code.

Thanks.

Chim’s picture

Thanks Piyuesh

karenann’s picture

Status: Active » Needs review
StatusFileSize
new1.31 KB

I had to manually apply the edits to 7.x-1.1 release. Here's a patch file for testing. First patch, hope I got this right. See also, http://drupal.org/node/1871536#comment-7316576

phayes’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

specified which cache