| 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) :
<?phpif (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 :
<?phpif (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
thanks komal pushed int he next release
#9
Hi!
Can not add banners to the site, tell me how! Thanks in advance!
#10
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:
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:
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
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.
<?phpfunction 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
I hit this same error, the fix posted here worked for me. I'm attaching it as a patch to make applying it easier.
#18
worked for me - thanks!!
#19
Same problem ... It took some difficulties but eventually it works fine for me too.
Thanks!
#20
Patch in #17 worked for me, thanks!
#21
Non-Coder besides HTML. How do I use a patch? Here is my error:
Notice: Trying to get property of non-object in marinelli_preprocess_comment() (line 204 of /home/dzired13/public_html/sites/all/themes/marinelli/template.php).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/dzired13/public_html/includes/entity.inc).
#22
:(
#23
I didn't use any patch. Replace a bit more than a dozen lines of code in template.php with a single copy-paste as per #13, including everything from "function" until the last "}" -- everything except the
<?phpand
?>
Take backup of the original file first though. Each opening "{" in PHP needs to have exactly one closing "}", or your pages will show the dreaded White Page of Death, and even if this wasn't your first time editing PHP, it'd be easy to make a mistake with copy-paste code replace.
#24
Thanks to Daedalon for the fix in comment #13 above!
I've since noticed though that the left-margin style on the comment-content div is only being set to 25px when I log out.
I think it's using the width of the currently logged in user's profile image, instead of the image of the user who posted that comment.
I think line 195:
if (isset($vars['user']->picture)) {should say:
if (isset($vars['comment']->picture)) {Seems to fix the issue for me.
#25
Thanks a lot for #13
#26
Hi,
Thanks a lot Daedalon, it work's for me!
Regards,
Santi
#27
#17 worked for me. Don't forget clean all caches.