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.
Comment | File | Size | Author |
---|---|---|---|
#17 | marinelli_preprocess_comment_errors-1183598-17.patch | 636 bytes | JeffSheltren |
Comments
Comment #1
mudtraining CreditAttribution: mudtraining commentedSame issue here, after I applied this fix: http://drupal.org/node/1027804
Comment #2
Tobion CreditAttribution: Tobion commentedSame issue for me. But it only occurs sometimes. After I refresh the page the error disappears for some time again.
Comment #3
komal.savla CreditAttribution: komal.savla commentedHi,
Replace the following code in template.php (line 202) :
with this :
Hope this helps.
Thanks,
Komal
Comment #4
RogueM CreditAttribution: RogueM commentedit does, thanks.
Comment #5
karilu_ec CreditAttribution: karilu_ec commentedThanks a lot. it fixes the error.
Comment #6
dsdart CreditAttribution: dsdart commentedFixed it for me too.
Comment #7
tedfeely CreditAttribution: tedfeely commentedEven 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!
Comment #8
Lioz CreditAttribution: Lioz commentedthanks komal pushed int he next release
Comment #9
Efremov_26 CreditAttribution: Efremov_26 commentedHi!
Can not add banners to the site, tell me how! Thanks in advance!
Comment #11
Daedalon CreditAttribution: Daedalon commentedBefore 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">
Comment #12
Tobion CreditAttribution: Tobion commentedIn your example it needs to be "if (isset($image_width))" to check whether the variable exists.
Comment #13
Daedalon CreditAttribution: Daedalon commentedThanks 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.
Comment #14
Daedalon CreditAttribution: Daedalon commentedLioz: 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.
Comment #15
jimbaer CreditAttribution: jimbaer commented+1
Comment #16
thedosmann CreditAttribution: thedosmann commentedSame fix worked here
Comment #17
JeffSheltren CreditAttribution: JeffSheltren commentedI hit this same error, the fix posted here worked for me. I'm attaching it as a patch to make applying it easier.
Comment #18
Toddv CreditAttribution: Toddv commentedworked for me - thanks!!
Comment #19
Moonlight CreditAttribution: Moonlight commentedSame problem ... It took some difficulties but eventually it works fine for me too.
Thanks!
Comment #20
twooten CreditAttribution: twooten commentedPatch in #17 worked for me, thanks!
Comment #21
jbeall1369 CreditAttribution: jbeall1369 commentedNon-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).
Comment #22
jbeall1369 CreditAttribution: jbeall1369 commented:(
Comment #23
Daedalon CreditAttribution: Daedalon commentedI 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
and
tags that Drupal's forums required for displaying the code with the proper formatting.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.
Comment #24
webmariner CreditAttribution: webmariner commentedThanks 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.
Comment #25
sifokl CreditAttribution: sifokl commentedThanks a lot for #13
Comment #26
santiagobf CreditAttribution: santiagobf commentedHi,
Thanks a lot Daedalon, it work's for me!
Regards,
Santi
Comment #27
jasom CreditAttribution: jasom commented#17 worked for me. Don't forget clean all caches.
Comment #28
phofab CreditAttribution: phofab commentedFollowing on from Comment 21, I am also a serious non coder and have no such knowledge. After a bit of deliberation I plucked up courage and made an attempt to substitute the defective code with solution #13, firstly on my Local/Host.
To assist others with little knowledge of the backend I offer the following steps:-
Locate where your Drupal program is stored, if on your Server it will be necessary to go into the Http/docs directory and look for a path something like:
sites/all/themes/marinelli/template.php
1. Back up your total Site on your local directory and/or the Directory on your Server.
2. Save template.php file to a temporary directory elsewhere on your computer
3. You now have a fall back position. DO NOT AMEND THIS FILE!
3(a) Open a new Directory, say “template amendment” and copy template.php into here and this becomes your working file.
4. Right click on template.php and select open with an editor like Dreamweaver or similar or possibly “notepad”
5. You should now see the script.
6. Go down and select/highlight lines 192 -210 (as described in #13), very carefully noting the exclusions- leave out first and last pieces of script ie:
and
7. Go back to the display of #13 and copy the recommended text.
8. Back to Notepad and Paste the new text into the highlighted area
9. Save it back to your original file #(3a), in “template amendment”, overwrite the old file. Submit and overwrite the amended file to your Host.
10. Close, reopen your Browser, clearing the history cache
11. You will hopefully see the messages disappear and not the white screen of death as described above, it is not a good look.
12. Save this now working file up to your server and locate the template.php and overwrite it.
On my attempt I worked on my Local Directory and it worked well so that I went to the next step and repeated the steps on my ISP Server, unfortunately rather than use the working and adjusted template.php on my local host, I started afresh with the result that I saw the white screen of death appear on both the local host and server version. I hadn’t taken a copy of the template.php file on my own computer so that I couldn’t over write the converted file. I went up to the Server and implemented the replacement of my backup and the on line site Website came back. I transferred down to my computer the once again faulty template.php file to another Directory and made the changes above, when it could be seen that it was working, locally, it was transferred back to the Server and everything worked as it should.
The FIX as described has worked for me and I thank you all for setting up the necessary code.
Comment #29
makokis CreditAttribution: makokis commented#17
Posted by JeffSheltren, thanks it works for me