I tried to use %session in a hidden field and I got the following error message everytime I viewed the form:
Recoverable fatal error: Object of class stdClass could not be converted to string in webform\webform.module on line 2079.

I think I managed to track the error down to a $node-object which I accidentially stored in $_SESSION somewhere else in my application, and the error is caused by a str_replace call in webform.module; I guess a simple if (!is_object(...)) at the right place would solve the problem, but I'm not sure if that's the best way... ?

Comments

quicksketch’s picture

Status: Active » Fixed

The token replacement would also fail if it ran into an array unexpectedly. For the time being I've just caste the replacement to a string to ensure it'll be replaced properly.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

flevour’s picture

Status: Closed (fixed) » Needs review

If $value is not a string, $replace and $find mess up, as they won't contain the same number of elements.
The patch below inserts an empty string replacement string in order to keep the 2 arrays in line.

Index: webform/webform.module
===================================================================
--- webform/webform.module	(revision 135)
+++ webform/webform.module	(working copy)
@@ -2115,11 +2115,13 @@
           if (is_string($value)) {
             $replace[] = (string)$value;
           }
+          else {
+            $replace[] = '';
+          }
         }
       }
     }
   }
-
   $string = str_replace($find, $replace, $string);
 
   // Clean up any unused tokens.
quicksketch’s picture

Version: 6.x-2.x-dev » 6.x-2.6
Status: Needs review » Closed (fixed)

This was corrected in the 2.7 version, which uses an entirely different replacement mechanism. Please reopen if the problem continues to exist.

tanguitcho’s picture

Hello ,

I'm trying to use %session with an array as a default value of a textfield : e.g. %session[myarray][key1]
However this is not working I get something like Array[key1] in the textfield ..

I've browsed a while for a possible solution but couldn't find any.

can anyone help me with this

thx

Config :
Drupal 6.x
webform 2.9