Drupal 4.7 - CVS as of date of this post
MySQL 4.x
PHP 4.4.x
Running Apache/MySQL on Debian

I'm getting an error on certain pages in my site - /node for example, as well as viewing nodes in their entirety. The errors that are generated are:

* warning: array_keys(): The first argument should be an array in /var/www/modules/user.module on line 339.
* warning: implode(): Bad arguments. in /var/www/modules/user.module on line 339.
* 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 DISTINCT(p.perm) FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/includes/database.mysql.inc on line 120.

I found this post which concerns the same errors, but the fix there doesn't work (or didn't work for me).

I'm aware that this may not be a bug and am OK with changing it to a support request if that is the generally accepted consensus, but I wanted to post it as a bug in case it was in order to bring it to the attention of the Drupal developers.

Regards

Patrick

Comments

greggles’s picture

The problem is in the "WHERE r.rid IN ()" section since there should be something inside of the "()". Likely there should be a variable in there that is not getting populated for some reason.

drewish’s picture

what modules are you running? anything that affects access control?

Patrick Nelson’s picture

drewish and greggles,

thx for responding to this post. I can see that something should be in that variable but I don't know what or why it's missing.

With regards to modules, the ones I have installed are:

actions
adminblock
administration
adsense
aggregator
archive
article
basicevent
block
blockbar
blog
blogapi
book
comment
contact
controlpanel
db_maintenance
devel
emailpage
event
filter
flexinode
formupdater
forum
front_page
gsitemap
help
hof
htmlwrap
insert_block
insert_view
members
menu
node
nodewords
page
path
pathauto
poll
porterstemmer
print
privatemsg
profile
profile_pages
profile_visit
recent_block
search
search404
sections
signup
simplenews
sitemenu
statistics
system
taxonomy
taxonomy_block
taxonomy_context
throttle
tinymce
tracker
troll
upload
user
userlists
views
watchdog
workflow

There are other modules uploaded to the modules directory but these are not enabled. They shouldn't affect anything, right? (Or am I wrong?). As far as I know none of the installed modules have any degree of access control at all.

However, I am planning to install taxonomy_access at some point. If installing it makes the problem disappear, is that a good thing as in the error is no longer being generated, or a bad thing because the error is still there but taxonomy_access is masking it? Or will it make no difference anyway?

Thx again for your help.

Patrick Nelson’s picture

Project: Drupal core » Privatemsg
Version: 4.7.0-beta4 » 4.7.x-1.x-dev
Component: node system » Code

I've tracked this error to my patched version of privatemsg module. Specifically to the setting under "Write to author" which allows you to "Display link with posts" (Provide a link to send private messages to users with posts they start).

Having this switched on produces that error.

I'm going to change this post to make it an issue under that module instead.

Thanks for your help though.

thomherfs’s picture

Has this been fixed yet?

Private messaging is a pretty basic and much needed function for most community-oriented websites. This is going to make 4.7 completely unusable for at least five sites that I have to update.

lunas’s picture

I'm still getting these errors on 4.7 beta 5. So, no, I guess it hasn't been fixed yet. If I could I would :)

knockingsoul’s picture

Its happening on my brand new DEV server running fresh copy of beta 5

drupal 4.7.0 beta 5

php 5
mysql 5
apache 2.x

I am guessing the developers are aware of this issue (I hope).

Hubert.

sorenp’s picture

Two hours of debugging yesterday night produced a little more info on the problem. As Patrik Nelson mentioned, the bug is related to the Write to Author setting and occures during the execution of privatemsg_link. Also, the problem only appears when I'm logged in as $user->uid == 1 and viewing nodes with $node->uid != 1.

Best Regards,

Sören

thomherfs’s picture

It's happening to me no matter what uid I'm using. I've tried it with users with different permission levels also. Still doesn't work. Anyone have any further information on how to solve this?

mjohnq3’s picture

I receive the same error only for uid 1 with 4.7.0 beta 6 on Xammp 1.5.1 under Windows XP. Right now this is the only non core module installed. Disabling it eliminates the problem.

kus’s picture

the same problem occurs with the buddy module v 1.57 , disabling helps.

ChrisKennedy’s picture

The problem is on line 19:

if (user_access('access private messages', $arg) && $arg->privatemsg_allow) {

Here is a quick fix that I think removes the error, although I'm not sure of the implications of this change:

if (!isset($arg->roles) || (user_access('access private messages', $arg) && $arg->privatemsg_allow)) {

PS: previewing this post did not show any preview - perhaps an error with drupal 4.7?

jmiccolis’s picture

chrisken I think you've found the right spot - but I've fixed it another way. It looks like the node object is being passed to the user_access() function, and it isn't to happy about it. So I've added some code to load the author of the node, and the pass that to user _load.

My privatemsg_link function looks like:

function privatemsg_link($type, $arg) {
  if (user_access('access private messages') && ($type == 'node' || $type == 'comment') && variable_get("privatemsg_link_$type", 0) && (isset($GLOBALS['user']->privatemsg_allow) ? $GLOBALS['user']->privatemsg_allow : 1)) {
    $author = user_load(array(uid => $arg->uid));
    if (user_access('access private messages', $author) && $author->privatemsg_allow) {
      return array(l(t('write to author'), "privatemsg/msgto/$arg->uid"));
    }
  }
}
hadishon’s picture

I'll put my two cents into this. I don't have any kind of private messaging modules installed and I get these errors when I call cron.

hadishon’s picture

I started disabling modules to try to locate the source...

I found that I no longer get the errors when I disable the devel.module

revival’s picture

Thanks jmiccolis --- that patch sorted it out nicely.

revival’s picture

I changed the patch to the one in post #12 ...

... but now users can't see the menu item that tells them how many private messages they have. Although it does appear when admin is logged in.

Any ideas how I can get this menu item back?

fool2’s picture

Remove the line in privatemsg_menu() that says 'type'=>MENU_CALLBACK,

And it should work.

fool2’s picture

Oh, forgot, it's in the second menu item, around line 50

revival’s picture

Sorry to be thick here, but which line should I comment out?

function privatemsg_menu($may_cache) {
  $items = array();
  global $user;

  if ($may_cache) {
    $items[] = array('path' => 'admin/settings/privatemsg',
        'title' => 'privatemsg',
        'callback' => 'privatemsg_configure');
  }
  else {
    $items[] = array('path' => 'privatemsg',
                     'title' => t('view inbox') . ' ('. (int)_privatemsg_get_new_messages() .')',
                     'callback' => 'privatemsg_page',
                     'access' => user_access('access private messages'),
                     'type' => (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1) ? MENU_DYNAMIC_ITEM : MENU_CALLBACK);
  }
  return $items;
}
revival’s picture

I removed

,
                    'type' => (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1) ? MENU_DYNAMIC_ITEM : MENU_CALLBACK)

but my users still can't see the menu item :(

lanesharon’s picture

I am getting this same errors in my 4.7 RC3, with no additional modules installed or configured (just core), when I navigate to:
administer -> comments -> configure tab

warning: array_keys(): The first argument should be an array in /myhome/me/public_html/gates-chili-high/modules/user.module on line 348.

warning: implode(): Bad arguments. in /myhome/me/public_html/gates-chili-high/modules/user.module on line 348.

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 DISTINCT(p.perm) FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /myhome/me/public_html/gates-chili-high/includes/database.mysql.inc on line 120.

droopy’s picture

I tried the fix suggested in #13 and this removed all the error messages from the front page. But now when I click on the username I get: warning: Attempt to assign property of non-object in D:\xampp\ost47\modules\privatemsg\privatemsg.module on line 264. The message function seems to work though.

killes@www.drop.org’s picture

I think the problem is that the handlng of roles in 4.7 has changed. in 4.7 users always have the "authenticated user" role, but it isn't saved in the database anymore. So you cannot assume that a user without $user->roles has no roles at all.

kchasney’s picture

Had the "p" "p" error and applied the patch. It worked but then I now receive the user.module error on line 348.

I see many many others have had this same problem for months. Is Privatemsg obsolete? Is there another module that does that same thing privatemsg does but w/o the errors? Tried both the 4.7 and cvs modules with and w/o patches. Nothing works and I kinda need this module. (maybe I should have stuck with 4.6)

Any help is appreciated.

dustyketchum’s picture

see if modifying user.module helps as a workaround....i had nearly identical error messages under different circumstances...

see
http://drupal.org/node/63375

silurius’s picture

Just adding myself to the discussion for tracking. I'll happily do my best to help validate any patches.

mindless’s picture

Status: Active » Closed (duplicate)

Please see fix/patch here.