Project:Marinelli
Version:7.x-3.0-beta11
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

after updating to beta 11 I'm getting log entries as follows:

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

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 177 of /home/chaosgen/public_html/drupal/includes/entity.inc).

I have narrowed it down to the function marinelli_preprocess_comment(&$vars) changes that occurred between beta10 and beta11, I think at least. I'm using the latest core, and recent (a couple of days old max) Rules and Entity API (not sure it matters). All is functioning, and my logs are clean if I revert to beta10.

Comments

#1

Same issue here, after I applied this fix: http://drupal.org/node/1027804

#2

Same issue for me. But it only occurs sometimes. After I refresh the page the error disappears for some time again.

#3

Hi,

Replace the following code in template.php (line 202) :

<?php
if (isset($vars['user']->picture)) {
   
// No.. I don't use style
   
if(!variable_get('user_picture_style')){
     
$size = variable_get('user_picture_dimensions');
     
$size = explode('x',$size);
     
$user_image['width'] = $size[0];
    }
    else{
     
//Yes... I use style
     
if ($picture = file_load($vars['comment']->picture->fid)) {
       
$user_image = image_get_info(image_style_path(variable_get('user_picture_style'), $picture->uri));
      }
    }
}
?>

with this :

<?php
if (isset($vars['user']->picture)) {
   
// No.. I don't use style
   
if(!variable_get('user_picture_style')){
     
$size = variable_get('user_picture_dimensions');
     
$size = explode('x',$size);
     
$user_image['width'] = $size[0];
    }
   else {
       if(isset(
$vars['comment']->picture->fid)) {  //Added this line
         //Yes... I use style
        
if ($picture = file_load($vars['comment']->picture->fid)) {
         
$user_image = image_get_info(image_style_path(variable_get('user_picture_style'), $picture->uri));
         }
      }
//Added this line
  
}
}
?>

Hope this helps.

Thanks,
Komal

#4

it does, thanks.

#5

Thanks a lot. it fixes the error.

#6

Fixed it for me too.

#7

Even though I did not have the problem, I'm very pleased to see that there are people responding to Drupal and Marinelli needs.

So, thank you!

#8

Status:active» fixed

thanks komal pushed int he next release

#9

Title:marinelli_preprocess_comment issue in beta11» Download banners

Hi!
Can not add banners to the site, tell me how! Thanks in advance!

#10

Status:fixed» closed (fixed)

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

#11

Before applying #3, I had the following error messages after viewing pages with comments:

  • Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 204 of /[siteroot]/sites/all/themes/marinelli/template.php).
  • Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /[siteroot]/includes/entity.inc).

After applying I get the following instead in the next page after viewing a page with comments, regardless of whether the next page is front page or an admin page:

  • Notice: Undefined variable: image_width in include() (line 4 of /[siteroot]/sites/all/themes/marinelli/templates/comment.tpl.php).

The message comes as many times as there were comments, even if they were from the same author. This is the line being referred to:

  <div style="margin-left:<?php print $image_width; ?>px;" class="comment-content">

The part after "div " and before "class" should be contained within an if that checks whether the $image_width is set and is the most efficient possible. Changing the line to be as follows the "margin-left" part was not anymore displayed in the HTML, but Drupal gave the same warning messages:

  <div <?php if ($image_width): ?>style="margin-left:<?php print $image_width; ?>px;" <?php endif; ?>class="comment-content">

#12

In your example it needs to be "if (isset($image_width))" to check whether the variable exists.

#13

Status:closed (fixed)» needs review

Thanks for the addition, Tobion.

I located the source of the error. It was a missing line in #3. Here's the correct code for template.php, line 192. No need for any changes to comment.tpl.php.

<?php
function marinelli_preprocess_comment(&$vars) {
 
$vars['classes_array'][] = $vars['zebra'];
 
$user_image = array('width' => 0);
  if (isset(
$vars['user']->picture)) {
   
// No.. I don't use style
   
if(!variable_get('user_picture_style')) {
     
$size = variable_get('user_picture_dimensions');
     
$size = explode('x',$size);
     
$user_image['width'] = $size[0];
    }
    else {
      if(isset(
$vars['comment']->picture->fid)) {
       
//Yes... I use style
       
if ($picture = file_load($vars['comment']->picture->fid)) {
         
$user_image = image_get_info(image_style_path(variable_get('user_picture_style'), $picture->uri));
        }
      }
    }
  }
 
$vars['image_width'] = $user_image['width'] + 25// This line was missing
}
?>

#14

Lioz: Any chance you're putting a beta12 or an rc1 out any time soon? At least this issue seems to come up with every new install and upgrade and I keep redirecting people here to manually patch their beta11.

#15

+1

#16

Same fix worked here

#17

Status:needs review» reviewed & tested by the community

I hit this same error, the fix posted here worked for me. I'm attaching it as a patch to make applying it easier.

AttachmentSize
marinelli_preprocess_comment_errors-1183598-17.patch 636 bytes

#18

worked for me - thanks!!

nobody click here