Hi!

We are using drupal ubercart 6.x-2.0 with File download (uc_file) module for virtual products.

Following error message, we are getting while the check out completed & after the paypal payment completes.

* recoverable fatal error: Object of class stdClass could not be converted to string in /home/dealback/public_html/includes/bootstrap.inc on line 774.
* warning: preg_match() expects parameter 2 to be string, object given in /home/dealback/public_html/includes/bootstrap.inc on line 777.

Thanks in advance.
IT Web - Q Solutions
Providing web solutions for open source communities

Comments

earthangelconsulting’s picture

Version: 6.x-2.0 » 6.x-2.2

i am getting the same error, in exactly the same situation, but with 6.x-2.2

it's a call to drupal_validate_utf8 that is being passed an object instead of a string

probably one of the calls to filter_xss or filter_xss_admin that are within Ubercart somewhere... and something that occurs only when there's downloadable files involved.

that's as far as i have managed to trace it.

HELP!

Peter 'Fish' Fisera
GoatVirus Technologies

earthangelconsulting’s picture

actually, could be a call to check_plain as well... though i haven't found out yet where this is happening in the uc_files module

earthangelconsulting’s picture

found a potential fix... if you are having this problem, see this thread in the Ubercart forums:

http://www.ubercart.org/forum/development/12710/error_occurs_when_checki...

landry’s picture

Version: 6.x-2.2 » 6.x-2.4

Bug still happens with 6.x-2.4. No more information can be gathered from the ubercart forum post.

If i dump $file_expiration in uc_file.ca.inc:uc_file_order_action_mail(), it's an array of file objects, definitely not strings. From my understanding, it needs to be an array of objects so that uc_file_token_values() calls theme_uc_file_downloads_token() with the correct parameters.

Looking at token_replace_multiple() code, the key in the 'replacements' array for $file_expiration is 'uc_file', which should be recognized as an object. According to the comment : "If an object is passed as value, the key should contain the object's type. For example, 'node', 'comment', or 'user'. The object will be used for building substitution values.". But then in our case it's an array of objects....

In the end, we have to find why is token_replace_multiple calling check_plain with each objects in the array ? It seems the more or less same code is present in uc_roles.ca.inc & uc_order.ca.inc..

landry’s picture

More details.. i'm pretty sure validate_utf8 is called by check_plain and not by filter_xss, but there's no check_plain() call involved in the codepath taken in token. and the use of filter_xss in ubercart is not involved in the 'send user an email' case.

landry’s picture

Status: Active » Closed (fixed)

okay, used the awesome trace module, and here's the php backtrace (i've stripped the thousands of line of file objects):

 E_RECOVERABLE_ERROR: Object of class stdClass could not be converted to string in `includes/bootstrap.inc':734
if (strlen($text) == 0) {
strlen(a file object) in `includes/bootstrap.inc':734
drupal_validate_utf8(a file object) in `includes/bootstrap.inc':701
check_plain(a file object) in `/etc/drupal/6/sites/all/modules/addresses/addresses.module':344
addresses_token_values('uc_file', array(file objects))
call_user_func_array('addresses_token_values', array(1 => 'uc_file', 2 => array(file objects)) in `/etc/drupal/6/sites/all/modules/token/token.module':296
token_get_values('uc_file', array(file objects)) `includes/module.inc':471
module_invoke_all('token_values', 'uc_file', array(file objects)) in `/etc/drupal/6/sites/all/modules/token/token.module':228
token_replace_multiple('[order-email]', array('global' => NULL, 'order' => ...) in uc_file

using addresses 6.x-1.05. Looking at the corresponding code in addresses_token_values() in this version of the module, the error now makes sense. updating to addresses 6.x-1.10 fixes the issue (well, i dunno if it works, but it doesn't break uc_file).
http://drupalcode.org/viewvc/drupal/contributions/modules/addresses/addr...

If someone encounters this issue, look at the other modules you have installed. Marking closed.