Can anyone help with this? For one of my cck content types (other content types seem to be unaffected) I get three php errors when attempting to submit a comment. The comment submission actually works, but the comments look ugly of course. Can anyone point me in the right direction?

  • warning: Invalid argument supplied for foreach() in /home/anthooa5/public_html/modules/node/node.module on line 521.
  • warning: implode() [function.implode]: Invalid arguments passed in /home/anthooa5/public_html/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/anthooa5/public_html/includes/database.mysql.inc on line 172.

Comments

anthonym’s picture

Bumping this up with some additional info:

User Miraploy reported the same errors here (also with no reply yet): http://drupal.org/node/250917

These errors go away when the comment options are changed to display on the same page rather than on a separate page. Maybe this will help someone give some clues as to what is going on? Any help would be greatly appreciated. Thanks.

Anthony
--
anthonymosakowski.com

kmillecam’s picture

I'm getting the same three errors but AFAIK I'm not using any CCK fields.

Could it have something to do with the MySQL version?

I'm running:

MySQL database 5.0.45
PHP 5.2.6

What are you running?

Kevin

http://www.webwiseone.com
It's all about community.

https://bkjdigital.com
We make magic.

Saganesque’s picture

I'm getting the same problem when I post a comment via email to the website. I'm using mailhandler with Messaging and Notifications modules to create a listserv kind of environment. When one of my users posts a comment on the website, it is entered just fine. The user receives their email as expected. However, when they reply, Drupal tries to digest the email and can't exactly. Mailhandler first returns the error:

No Data!!

And then the errors cited by anthonym repeat themselves several times afterward. However, what I found in my own case is that the comments **are** making it into the db. That is, if I go to:

admin/content/comment

I can see my comment there. If I click the edit link, I can edit it. But if I click the subject-line link on the /admin/content/comment page for that entry, I get a "page not found". This is because the destination of the link needs to be something like

node/180#comment-157

but instead it is:

node/0#comment-157

The first two numbers of the node are being clipped. I wish I could look in the database, but I can only do this testing on the live site and I don't have immediate access to the db there. I strongly suspect that the info in the db is mangled, but it may also be that they are being retrieved wrong for some reason.

Hope this helps.

-Saganesque

jeuelc’s picture

I have the same error. I can solve the problem but it will take time. The most time consuming part here will be the task of locating where the said query is located. If somebody can help me pinpoint where it is located, then it will lessen the time to solve this.
Please, everyone. Let's cooperate. If you know where this is, tell me and we'll solve this.

Looking forward,
jeuelc

Saganesque’s picture

Maybe it is fixed? If not, perhaps this points the way?

http://drupal.org/node/180529

Saganesque’s picture

The culprit piece of code in the other post is inside node_load(), node.module, called from cron:

    // Turn the conditions into a query.
    foreach ($param as $key => $value) {
      $cond[] = 'n.'. db_escape_string($key) ." = '%s'";
      $arguments[] = $value;
    }
    $cond = implode(' AND ', $cond);
Saganesque’s picture

I still have to believe that the way the comment was actually created with the truncated path after "node/" should indicate something key about the guts of the malfunction.

This is in an important one for us to fix and is very high on our list of priorities.

jeuelc’s picture

This problem is already solved. I accidentally found a patch is this site. I cannot remember the specific location (sorry). It worked out fine. The three (3) errors were avoided ust by adding four (4) lines of code in the node_load function of the node.module.
The following will be the resulting code of the said function after editting:

function node_load($param = array(), $revision = NULL, $reset = NULL) {
  static $nodes = array();

  if ($reset) {
    $nodes = array();
  }

  $cachable = ($revision == NULL);
  $arguments = array();
  if (is_numeric($param)) {
    if ($cachable && isset($nodes[$param])) {
      return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
    }
    $cond = 'n.nid = %d';
    $arguments[] = $param;
  }
  else {
  // Turn the conditions into a query.
    $cond = array();                                   //Added this line to avoid the error
    if( $param==null || !is_array($param) ){    //Added this line to avoid the error
    return null;                                           //Added this line to avoid the error
    }                                                        //Added this line to avoid the error
    foreach ($param as $key => $value) {
    $cond[] = 'n.'. db_escape_string($key) ." = '%s'";
    $arguments[] = $value;
    }
  $cond = implode(' AND ', $cond);
  }

  // Retrieve the node.
  // No db_rewrite_sql is applied so as to get complete indexing for search.
  if ($revision) {
    array_unshift($arguments, $revision);
    $node = db_fetch_object(db_query('SELECT n.nid, r.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.nid = n.nid AND r.vid = %d WHERE '. $cond,  
    $arguments));
  }
  else {
    $node = db_fetch_object(db_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 '. $cond, $arguments));
  }

  if ($node->nid) {
    // Call the node specific callback (if any) and piggy-back the
    // results to the node or overwrite some values.
    if ($extra = node_invoke($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }

    if ($extra = node_invoke_nodeapi($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }
    if ($cachable) {
      $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
    }
  }

  return $node;
}
Saganesque’s picture

Can you at least tell me the name of the patch so I can google it? I really need to get this fixed! Which lines were fixed?

Saganesque’s picture

As far as I can tell, this doesn't fix the problem. It just hides errors when they appear! The comment path isn't being built right, and that's why the error emerges!

chipk’s picture

Any resolution here? I have the same bewildering problem.

Saganesque’s picture

The problem is likely a call by some module to node_load. I had to do some clunky debugging to find out which, but in my case it was CaseTracker that wasn't playing right with mailhandler, and by extension, node_load. The very dirty method of debugging I used I found here:

http://www.lullabot.com/articles/quick_and_dirty_debugging

On the upside, the page uses this bug as the example:

warning: Invalid argument supplied for foreach() in /modules/node/node.module on line 504.

Look familiar? :-)

-Saganesque

chipk’s picture

Familiar indeed - the clues at lullabot led me to the problem in my own code : in _phptemplate_variables() I was not checking for existence of $vars['node'] before calling node_load($vars['node']->nid) .

Thanks!

chipk’s picture

Familiar indeed - the clues at lullabot led me to the problem in my own code : in _phptemplate_variables() I was not checking for existence of $vars['node'] before calling node_load($vars['node']->nid) .

Thanks!