Error with %session when $_SESSION contains objects (...)

bforchhammer - June 26, 2008 - 18:47
Project:Webform
Version:6.x-2.6
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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... ?

#1

quicksketch - June 30, 2008 - 00:09
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.

#2

Anonymous (not verified) - July 14, 2008 - 00:13
Status:fixed» closed

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

#3

flevour - February 25, 2009 - 12:18
Status:closed» 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.

#4

quicksketch - November 6, 2009 - 01:04
Version:6.x-2.x-dev» 6.x-2.6
Status:needs review» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.