I have installed ubercart on my sky themed site to try it out. When I have a product with attributes, I get this error message:

recoverable fatal error: Object of class stdClass could not be converted to string in /var/www/html/sites/all/themes/sky/functions/theme-custom.inc on line 25.

Line 25 is

$items[] = $attribute .'="'. $data .'"';

I have ubercart v 6.x-2.0-rc3

Thanks for your help,
Heather

Comments

Dusty’s picture

Heather,

I have the same problem. Have you been able to solve it?

Thanks, Roman

jacine’s picture

The issue has to do with this: http://drupal.org/node/478952

Ubercart devs "wont fix" so I am left with 2 options:

A - Because of one module, change the namespacing everywhere, which I'm not thrilled about.
B - Create a special case to handle Ubercart differently.

Either way, this means I need to install Ubercart, figure out some sort of solution and test and I wont be able to do that for a few days.

Dusty’s picture

Thanks, I understand the bigger issue. However, there is a interim (?) fix that will solve the problem. You should simply check if $data is a string object prior to treating it as string. It is not Ubercart specific and, if nothing else, is a good coding practice.

Change:

$items[] = $attribute .'="'. $data .'"';

To:

if (is_string($data)) {
    $items[] = $attribute .'="'. $data .'"';
}

This solves the immediate problem. Could you please tell me wheter or not this change would break something else?

Thanks,
Roman

zapscribbles’s picture

Version: 6.x-3.7 » 6.x-3.9

I am having the same problem with 3.9. Didn't start getting this error until installing Ubercart and has only come up when viewing products so far (all my products have attributes so assuming I am in the same situation as Heather)

zapscribbles’s picture

Sorry, forgot to mention I tried the code change in comment #3 and it worked. Can this be made permanent from now on?

khanz’s picture

I was also facing the same issue until i tried the code in comment #3, and its working perfectly.Thanks

kvoltz’s picture

Hey Guys,

I am getting the same problem but might not be savvy enough to understand everything that you have listed above. I have made the correction as per the comments made by Dusty. I made these correction to the "theme-custom.inc" file, which seems to be the place to do it (?). However, this is the error I am getting:

Parse error: syntax error, unexpected $end in /home1/kvoltzde/public_html/waggintailscart/sites/all/themes/sky/functions/theme-custom.inc on line 61

of course, if I try to not make this correction... the whole site simply goes blank. Any chance someone can guide me on this?

Thanks for your help

kvoltz’s picture

Any chance someone can help here?

Thanks so much!

aimutch’s picture

Did you replace the code exactly as it's listed above? It sounds like you might have missed something in the copy and paste.

kvoltz’s picture

Hi aimutch,

Yeah, pretty sure I copied the issue extactly. There is one line in the module file that says

$items[] = $attribute .'="'. $data .'"';

and I replaced that line, and that line only with

if (is_string($data)) {
    $items[] = $attribute .'="'. $data .'"';
}

What I think is going on... is that there is another step here that is typically "understood" but since I am relatively new to all of this, I am missing it completely.

thanks so much for getting back to me.

aimutch’s picture

OK. I haven't used Ubercart and am not sure I can create a helpful test case to see if I can work out that bug. Hopefully, another Ubercart user will post back here. Did you check at the Ubercart module for help? Someone there will probably see your request more quickly than here.

kvoltz’s picture

Thanks for getting back. I think that is where I am headed next. I will post back here with whatever info I come up with. Thanks again for your help. Definitely appreciated.

kvoltz’s picture

Well, I have a bit of info, but it isn't too great. This seems to be an actual issue.

http://www.ubercart.org/forum/support/11534/object_class_stdclass_could_...

kvoltz’s picture

I have shifted these posts to a bug report here:

http://drupal.org/node/595678

Thanks again for the help, hopefully we can get this sorted out.

jsims281’s picture

It's possible that $attribute could be an array. Try putting this:

print "<pre>"; //this tag is just to make the output more readable

print "Attribute variable contains:<br>";
print_r($attribute);

print "<hr>";

print "Data variable contains:<br>";
print_r($data);

print "</pre>";

in your tpl file somewhere and see what it outputs. If you get a list of various different things for either of those, then they are an array and you can't handle them in the way this theme is trying to do.

I don't have a sky site to test this on, what do you see?

jacine’s picture

Status: Active » Fixed

I just committed a "fix" for this to HEAD, by changing the namespace used. We are no longer using $attributes, but instead $block_attributes, $node_attributes, etc. I have not tested it with Ubercart, but it should solved.

Details here: http://drupal.org/cvs?commit=312338

Status: Fixed » Closed (fixed)

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

mac_man_luke’s picture

Version: 6.x-3.9 » 6.x-3.10
Category: support » bug
Status: Closed (fixed) » Active

Error still occurs since last update

jacine’s picture

If that's the case, I am fresh out of time and will to deal this. Unless someone comes along with a patch, and a detailed report of the problem, and others test it, I'm not moving on this. It's just not a priority for me right now.

deggertsen’s picture

Well at least the fix given by Dusty in #3 gets rid of the errors. I have no idea if it fixes the problem though.

pltmdude’s picture

I just wanted to chime in and say that I'm having the same problem, but would love to use this excellent theme. Unfortunately, I'm new to drupal, so I won't be much help yet in tracking down the problem. I wish I could.

Thanks in advance to anyone who can help us fix this.

Sky version 6.x-3.10
Ubercart 6.x-2.4
Drupal 6.19

Jeff Burnz’s picture

Anyone have a status on this issue, don't want to close but its been open a long time with no updates.