Whenever opening a users profile page with an user picture present it throws an error message.
Strange thing is, that the first visit doesn't trigger the error. The second visit (refresh page or just visit some other page) shows the error:

* warning: Invalid argument supplied for foreach() in /modules/node/node.module on line 563.
* warning: implode() [function.implode]: Bad arguments. in /modules/node/node.module on line 567.
* 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 /includes/database.mysql.inc on line 174.
* warning: Invalid argument supplied for foreach() in /modules/node/node.module on line 563.
* warning: implode() [function.implode]: Bad arguments. in /modules/node/node.module on line 567.
* 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 /includes/database.mysql.inc on line 174.

Profile pages of user that havent uploaded a picture doesnt produce the error.
Disabling the OGUR module or disabling picture support in drupal prevents the error.

Any suggestions, folks?

CommentFileSizeAuthor
#6 og_user_test.sql_.txt5.91 KBdigidoo

Comments

somebodysysop’s picture

What version of node.module? What is on those lines?

digidoo’s picture

Hi there,

It's drupal v5.15 and node.module version:

// $Id: node.module,v 1.776.2.33 2009/01/14 23:32:14 drumm Exp $

The lines 563 and 567 are refering to the node_load function:

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.
    foreach ($param as $key => $value) {                             <----------- line 563 
      $cond[] = 'n.'. db_escape_table($key) ." = '%s'";
      $arguments[] = $value;
    }
    $cond = implode(' AND ', $cond);                             <----------- line 567
  }

  // Retrieve the node.
  // No db_rewrite_sql is applied so as to get complete indexing for search.
  if ($revision) {
    array_unshift($arguments, $revision);

I did some code digging and discovered a piece of responsible code in og_user_roles.module, somewhere around line 1500:

/** --DD-- ERROR ON USER PROFILE PAGE
  // Add the group roles to $user->roles if this is a group
  // This should only be effective until the next global $user call
  if ($op == 'load') {
    $roles = og_user_roles_all_roles($user); // This returns normal $user->roles and includes OG roles if any
    $user->roles = $roles;
  } // end $op load
**/

Commenting that out takes away half of the error message. But I still dont understand what going on there...
I hope to get the code straight to fit to OG v8.0 (was migrating from OG v7.3).

digidoo’s picture

replying...

somebodysysop’s picture

Thanks for the response.

The only portion of the "responsible" code that would touch "node_load" is og_user_roles_all_roles($user).

That function loads, or attempts to load, group nodes several times using "node_load".

I believe what needs to happen here is that each of those requests needs to be verified before it is sent to node_load. My guess is the ones that depend upon $_SESSION['og_last']->nid would be the offending ones. That's been the source of recent misery here: http://drupal.org/node/367417

This gives me something to work with that makes sense. Thanks.

somebodysysop’s picture

Status: Active » Postponed (maintainer needs more info)

I need you to turn on OG User Test (admin->organic groups->ogur settings->Test/Debug): place a check next to: Output debug data to og_user_test table?

Do the same thing you do that generates the error you reported.

Take note of the URL where the error takes place. I need the output from og_user_test table at that URL.

This should help to pinpoint in ogur exactly where the offending node_load is taking place.

Thanks.

digidoo’s picture

StatusFileSize
new5.91 KB

Here you go.
The error message at URL /user/16 and attached the output of og_user_test table at that URL.


* warning: Invalid argument supplied for foreach() in /var/www/virtual/intra/htdocs/modules/node/node.module on line 563.
* warning: implode() [function.implode]: Bad arguments. in /var/www/virtual/intra/htdocs/modules/node/node.module on line 567.
* 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 /var/www/virtual/intra/htdocs/includes/database.mysql.inc on line 174.
* warning: Invalid argument supplied for foreach() in /var/www/virtual/intra/htdocs/modules/node/node.module on line 563.
* warning: implode() [function.implode]: Bad arguments. in /var/www/virtual/intra/htdocs/modules/node/node.module on line 567.
* 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 /var/www/virtual/intra/htdocs/includes/database.mysql.inc on line 174.

somebodysysop’s picture

Status: Postponed (maintainer needs more info) » Needs review

Thanks for the output. Located what I think is the offending section and modified. Committed to cvs. Should be available for download in DEV release in 12 hours.

Please download and test and let me know if it works.

somebodysysop’s picture

Oops. Sorry. Updated 6.x dev, not 5.x. Doing that now.

somebodysysop’s picture

5.x changes now committed to cvs.

somebodysysop’s picture

Status: Needs review » Fixed

This is related to this issue: http://drupal.org/node/381092

Fixed in 5.x-3.x-dev.

somebodysysop’s picture

Assigned: Unassigned » somebodysysop

Code fix committed to 5.x-3.6 release.

digidoo’s picture

Version: 5.x-3.5 » 5.x-3.6

Hi there, that's good news.

But I just updated to v3.6 and found that the og_user_roles.module is the same than in v3.5 ?

somebodysysop’s picture

Version: 5.x-3.6 » 5.x-3.7

I don't know what the deal is with that. The fix is DEFINATELY in 5.x-3.7. I verified.

Status: Fixed » Closed (fixed)

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