I keep getting these warnings when a forum topic is initially previewed:
* warning: Invalid argument supplied for foreach() in /home/c/l/clikhost/public_html/wwgolf/modules/node/node.module on line 521.
* warning: implode() [function.implode]: Bad arguments. in /home/c/l/clikhost/public_html/wwgolf/modules/node/node.module on line 525.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /home/c/l/clikhost/public_html/wwgolf/includes/database.mysql.inc on line 172.
These warnings don't prevent the comment from being posted, but once it is all the further comments are listed newest first when I have the comments set to oldest first.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 260136.patch | 852 bytes | neclimdul |
| #5 | printout_of_arrays.txt | 10.31 KB | sgdev |
Comments
Comment #1
sgdev commentedI have the same problem with 5.x-1.0-alpha8. When Advanced Forum is installed, if I respond to a post and click "Preview comment" I get the following error:
* warning: Invalid argument supplied for foreach() in /htdocs/modules/node/node.module on line 521.
* warning: implode() [function.implode]: Bad arguments. in /htdocs/modules/node/node.module on line 525.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /htdocs/includes/database.mysql.inc on line 172.
If I remove Advanced Forum and just use basic Drupal Forums, I don't get this error. Also much like DruPaulus, the warnings don't prevent the comment from being posted, but does change the comment order.
Comment #2
DruPaulus commentedron_s, what other modules do you have installed? I noticed when I switch off the quote module the problem goes away.
I looked for node_load in quote.module and replaced
$node = node_load(arg(1));
with
$node = node_load(array('nid' => $nid));
This seems to have done the trick and gotten rid of the warnings, but the new comment is still sticking to the top.
Comment #3
DruPaulus commentedThis isn't the best fix, it has also gotten rid of the quote link on past comments.
Comment #4
michelleI can't reproduce this on any of my sites and they all use the quote module. I'll leave this open for a while in case someone can provide more information but I can't fix what I can't reproduce.
Michelle
Comment #5
sgdev commentedMichelle,
I appreciate all the work you've done on both the Advanced Profile and Advanced Forum modules. Very good stuff. I would like to say though when it comes to these types of issues, you should be working with us to try to identify what's wrong rather than just saying you can't reproduce it. There is clearly a problem and we're trying to help.
That being said, I have looked more closely at your Advanced Forum module and the Quote module. The problem occurs in the
quote_linkfunction of the quote.module file. This problem *only* occurs when the Advanced Forum module is installed. I also believe it is more than just a module installation issue. Most likely this also has to do with module configuration settings.The code where the issue occurs in quote.module is as follows:
And part of the issue with advanced_forum.module is in the following code in
advanced_forum_preprocess_commentfunction:First, let's discuss what happens when Advanced Forum is not installed and out-of-the-box Drupal Forums is used. In this situation, if a user clicks "Preview comment", a page is displayed with the new comment at the top, and the reference node at the bottom. What is sent to the
quote_linkfunction in quote.module is nothing for the comment, and$type = 'node'for the reference node. This is used to build the "quote" hyperlink. This makes sense, because why would there be a quote link for a comment which is just a preview?However with Advanced Forum, something different happens. Two requests are sent to the
quote_linkfunction. First, a request is sent to put a quote link on the preview comment ($type = 'comment') and second, a request is sent to put a quote link on the referenced node at the bottom of the page ($type = 'node').Maybe it's the order in which functions are being processed or how Advanced Forum is interacting with other settings? I think a key part of the problem is that
$links = module_invoke_all('link', 'comment', $vars['comment'], 1);in Advanced Forum is run for *all* modules, when this should not be run for the Quote module on a preview comment. We do not want a quote button on a previewed comment, yet I think Advanced Forum is attempting to do this on line 176 in your code.I am also attaching a print out of a few key arrays in
advanced_forum_preprocess_comment. In here I have also included the value of $type as received by the Quote module. It's clear that Advanced Forum with the module_invoke_all is performing the quote function more than once.Comment #6
michelle"you should be working with us to try to identify what's wrong rather than just saying you can't reproduce it"
Should? There is no "should" here. I've spent a great deal of my extremely limited free time to work on these two modules and provide support for free. Not only do I not get paid for this, I've actually had to turn down paying work because the modules take too much of my time. So don't tell me what I "should" be doing. I have enough work to do on this module that I simply can't be spending a lot of time trying to debug something that I can't reproduce. How am I supposed to figure out what's causing it if it doesn't happen for me?! Magic?
That said, it looks like you've spent some time analyzing the problem amd I will take a look at it and see if I can figure something out based on that. It may be as simple as not calling that code when we're previewing. I don't know right off how to tell if we're in preview mode, so I'll have to investigate. It will likely be a while before I can get to this so if anyone comes up with a fix in the mean time, that would be great.
So thanks for investigating but, please, if you don't want to piss off volunteers, don't tell them what they "should" be doing.
Michelle
Comment #7
sgdev commentedHmmm ... I think you're reading a bit too much into the word 'should'. I appreciate all you're doing and I hope you understand you're not the only one volunteering lots of time. My only point is I'm trying to help you, therefore I would think you would want to take advantage of my willingness to do so. Clearly I'm not just an average joe saying "I've got a problem, fix it for me".
I'm always willing to debug, poke around and try different options to help solve the problem. However this is your module, so I don't know all the ins-and-outs of your design approach. Absolutely I understand not being able to reproduce the problem makes it difficult to solve. But it's not impossible.
I know you have lots of other things to do on your priority list. I think though with a bit of discussion back and forth we can figure this out. I provided some information on my end, and I'm sure you'll be able to look at how the core Drupal Forum module works with previewing comments, you'll ask me some questions or want me to try something in the code, and we'll make headway. Like I said, I'm just trying to help.
Comment #8
michelleI know I'm not the only volunteer around here and I don't think anyone who is volunteering appreciates being told what they "should" be doing. That's great if you want to help but all I had at the time of my post was "there is this error when advforum is installed and it seems to be related to quote". That's not a lot to go on considering I use quote on all of my sites and don't have this problem. So, clearly, advforum and quote do work together most of the time but there is some weirdness somewhere for a couple of people. When faced with trying to debug that or work on bugs that I can reproduce, it seems like a simple choice to me. If, however, you're willing to do the leg work and get this figured out, I'm certainly not saying I don't want your help or I won't take a patch. And if there's something I can do on my end to help out, I'm willing to do that, too, when I get back to work on this. At the moment, however, I'm on vacation with limited computer time and am not doing much more than trying to keep the issue queue under control so I'm not completely buried when I get home.
Michelle
Comment #9
sgdev commentedI have created a temporary fix for this problem, but I'm not really sure this is the best approach. Since Advanced Forum is sending a request to the Quote module for both the comment and the reference node at the bottom, I have edited the
quote_linkfunction around line 45 in quote.module as so:I have edited this conditional to include
if (arg(1) != 'reply'). This basically skips over attempting to create a quote link for a comment on the preview page.Comment #10
sgdev commentedAlso I just noticed, someone else posted about this issue back on May 15 here: http://drupal.org/node/258807. I directed them to look at this thread. Funny that this person is having the issue with Zen but not with Garland. We are running our own theme, but it is based heavily on Garland.
Comment #12
neclimdulIf that's the case then this isn't a bug with advanced forums. The quote module is making an assumption about the menu path that is not true of comments. In fact, the comment api could be called here from any url path and in those cases it will always cause this problem.
Its actually an easy fix though. replacing arg(1) with $post->nid should get rid of all the errors and properly load the node object.
I'm going to move this to the proper queue.
Comment #13
neclimdulsorry I said comment api but I meant hook_link().
Comment #14
amnion commentedThis seems to only affect my site when you hit "reply" to a comment, but not when you "reply" to the original post. Would it work if we just changed it so the reply button in comments actually pointed to the reply in the original post, so in effect you're not actually replying to a comment, but to the topic or node?
I realize this is an issue for the quote module but I was directed here from another post about Advanced Forum.
Comment #15
sgdev commentedI don't really think that is possible, because by doing so you will remove all opportunity for threaded discussions. Some sites want flat comments (e.g., all comments are attached to the original node), while others want to allow users to show their comments as a direct response to another individual's comments.
Modules need to be flexible enough to handle both situations, and as it stands right now, they do.
Comment #16
dami commentedI have the same problem, using Advanced Forum 5.x-1.0-alpha8 with quote Quote 5.x-1.3.
The fix in #12 works for me, thanks.
Comment #17
neclimdulI haven't tested this but this is what i was talking about. I'm pretty sure this is how I worked around this a while back.
Comment #18
amnion commentedI've never applied a patch before, do you just put the code into that file or do you replace it, how does that work?
Comment #19
sgdev commentedYou can either use a patch program (different options whether you're running Linux or Windows), or you can do it manually. Manually is rather simple for a case like this. Plus (+) means add the line, minus (-) means remove it, the top of the section tells you what file the change is in (quote/quote.module), and around what line the change occurs. In this case, it's around line 57.
Comment #20
tumblingmug commentedHad exact the same issue. Thanks to neclimdul, replacing "arg(1)" with "$post->nid" on line 59 in the file quote.module, (v 1.29.2.8 2007/08/11 19:51:20) did the job to get rid of all warnings.
Comment #21
Zen commentedFixed. Thanks.
Comment #22
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.