In what has otherwise been a wonderful experience with the new installation (www.metal-hq.com), me and other users
(including anonymous users) get the following error in an unmissable bright red box! This error happens typically when a user
visits a blog entry and then goes one level up - back to the home page, for example.

I'm a newbie but have built usable drupal sites before without getting into too much of php and such... kindly tell me what I
should do to correct this problem:

Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 187 of /home/metalhqc/public_html/sites/all/themes/marinelli/template.php).
Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 187 of /home/metalhqc/public_html/sites/all/themes/marinelli/template.php).

When I look for the offending line, the relevant block of code reads from line 182-188 like this. Line 187 is second last from below.

function marinelli_preprocess_comment(&$vars){
	$vars['classes_array'][] = $vars['zebra'];
	
	$account_uid = $vars['content']['comment_body']['#object']->uid;
	$comment_author = user_load($account_uid);
	$user_image = image_get_info(image_style_path(variable_get('user_picture_style'), $comment_author->picture->uri));
	$vars['image_width'] = $user_image['width']+25;

Help, anyone?

Comments

mavimo’s picture

Assigned: Unassigned » mavimo
mavimo’s picture

Please try to replace function marinelli_preprocess_comment with:

function marinelli_preprocess_comment(&$vars){
  $vars['classes_array'][] = $vars['zebra'];
  if (isset($vars['user']->picture)) {
    $picture = file_load($vars['user']->picture);
    $user_image = image_get_info(image_style_path(variable_get('user_picture_style'), $picture->uri));
  } else {
    $user_image = array('width' => 0);
  }
  $vars['image_width'] = $user_image['width'] + 25;
}
mavimo’s picture

Status: Active » Needs review
narayan kumar’s picture

Thanks for taking the time to help. The problem is gone! Wow, indeed.

Carl242’s picture

Hi. I replaced the code as written above, but the error changed. I now get:

Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 186 of /home/yourspa4/public_html/_sites/microcarusa/sites/all/themes/marinelli-7.x-3.0-beta4/marinelli/template.php).

Also, I notice that the username does not show up in the comment field (probably will make a new ticket for that, but something tells me it might be related).

Thanks for the help, and for the awesome theme!

Lioz’s picture

Status: Needs review » Fixed
novakov’s picture

#2 didnt worked for me, same errors (only in admin section and all seems to be working)

badre’s picture

Version: 7.x-3.0-beta4 » 7.x-3.0-beta6
Status: Fixed » Active

Same problem with red box:
Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 186 of /var/www/drupal7rc4/sites/all/themes/marinelli/template.php).

badre’s picture

sorry first time registered - for beta 4 status not fixed

ThumbsUpDavid’s picture

I'm having this same problem as well...#2 did not change anything, either.

sammyframson’s picture

Version: 7.x-3.0-beta6 » 7.x-3.0-beta5

I'm having the same issue and #2 didn't work for me either. This is actually not a new install either. I have had the theme installed with no issues for about a week and this issues just appeared yesterday.

Error:
Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 186 of /.../sites/all/themes/marinelli/template.php).

mavimo’s picture

Status: Active » Needs review

replace function marinelli_preprocess_comment with:

/**
 * Additional comment variables
 */
function marinelli_preprocess_comment(&$vars) {
  $vars['classes_array'][] = $vars['zebra'];

  $user_image = array('width' => 0);
  if (isset($vars['user']->picture)) {
    if ($picture = file_load($vars['user']->picture)) {
      $user_image = image_get_info(image_style_path(variable_get('user_picture_style'), $picture->uri));
    }
  }
  $vars['image_width'] = $user_image['width'] + 25;
}

let us know if it work.

jpuchalski’s picture

Version: 7.x-3.0-beta5 » 7.x-3.0-beta6

I applied the fix shown above after having seen the same error. It seems to have solved the problem in my case. I ran into the issue while creating forum posts. I'm using:

WYSIWYG 7.x-2.0
IMCE Wysiwyg API bridge 7.x-1.x-dev
IMCE 7.x-1.1
CKEditor 3.5

Hope this helps

Joe

marta_yo’s picture

Status: Fixed » Needs review

#12 works for me, thanks!

sammyframson’s picture

I haven't seen this error in some time. It appears to have been fixed with the update from number 2...

Lioz’s picture

Status: Needs review » Fixed

Status: Needs review » Closed (fixed)

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

jimpanse’s picture

Version: 7.x-3.0-beta6 » 7.x-3.0-beta9

I get the same error if user use the search function.

If a user has a profile picture it works without an error.

Without a picture I'll get the red error box:

Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 204 from /mnt/web4/12/90/52037890/htdocs/sites/all/themes/marinelli/template.php).

And with the "Patch" i'll get this error:

Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 196 from /mnt/web4/12/90/52037890/htdocs/sites/all/themes/marinelli/template.php).

Daedalon’s picture

Jimpanse, try updating to Marinelli 7.x-3.0-beta11. If you get errors after that, please see this patch that fixed them for me.

gerguaigua’s picture

Version: 7.x-3.0-beta9 » 7.x-3.0-beta11
Assigned: mavimo » Unassigned
Priority: Normal » Minor

Yo resolví el error con el post 12. En Versión 7.x-3.0-beta11

MDV’s picture

Perfect! the code that post mavimo, works perfect for me, thank you!!

manoloka’s picture

I confirm that #12 also fixed my issues

Thanks