Multiple warning with gravatar in OG faces

ashledombos - May 12, 2009 - 18:25
Project:Gravatar integration
Version:6.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Dave Reid
Status:closed
Description

Hello,
the module gravatar was working nice for me until i had to change the provider. I did a backup/migrate of databases, and all seems ok, except that gravatar with organic groups : when i go to an organic group faces, and if this group contains user with gravatar icons, i can't see the gravatar icons (only drupal icons) and i have got these warnings :

* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.
* warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
* warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 502.
* 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 502.

What is missing ?
Regards,
Raphaël

#1

Dave Reid - May 12, 2009 - 18:34

That's really odd. What I can guess is happening is that an incomplete user object is being passed into user_access(), which is what is causing the errors your are seeing. If you could modify your modules/user/user.module file around line 502 and add:

if (empty($account->roles)) {
  drupal_set_message('Account: ' . var_export($account, TRUE), 'error');
}

#2

satcom74 - May 18, 2009 - 02:43

Had that same problem on Members faces with 6.x-1.6 and 1.x-dev. I was using the stock members faces with OG. I had to go back to 6.x-1.5 to get it to work again.

#3

ashledombos - May 21, 2009 - 21:37

Sorry for long answer, i was ill :)

so i did it, i add the line, and now i have

    * Account: stdClass::__set_state(array( 'uid' => '49', 'name' => 'dr_st', 'picture' => ' ', ))
    * warning: array_fill() [function.array-fill]: Number of elements must be positive in /var/www/drupal/includes/database.inc on line 241.
    * warning: implode() [function.implode]: Invalid arguments passed in /var/www/drupal/includes/database.inc on line 241.
    * warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/drupal/modules/user/user.module on line 505.
    * 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 p.perm FROM role r INNER JOIN permission p ON p.rid = r.rid WHERE r.rid IN () in /var/www/drupal/modules/user/user.module on line 505.
...

And so on, for each user that have not a profile picture (uid 49, in my example, does not have a picture)

Raphaël

#4

Dave Reid - May 21, 2009 - 21:39
Assigned to:Anonymous» Dave Reid

Ok, yeah that's definitely an incomplete user data. It should have an object variable 'roles' which is used by user_access(), and that function is used by gravatar. I'll try and get a test og installed and see if I can solve this.

#5

ashledombos - May 22, 2009 - 20:06

thank you very much, i think the database must have loose something during the migration :/

#6

ashledombos - June 8, 2009 - 16:35

BTW, do you know a way to fix the database by hand or with a script ?

#7

Dave Reid - June 14, 2009 - 03:15
Status:active» fixed

I got og installed and running on my local install and committed a temporary fix for this. The main problem is if you have a view (via Views) that users a 'user picture' field display, it does not provide the full user object (like from user_load()) which has all the role data available for permission checking. I'm going to file an issue for View to hopefully fix this in the future, but I'll also leave this fix in the Gravatar code for a while just in case.

Considering fixed!
http://drupal.org/cvs?commit=225066

#8

Dave Reid - June 14, 2009 - 04:01

For those interested I filed an issue with Views at #491082: Provide a fully-loaded user object with the user picture field.

#9

System Message - June 28, 2009 - 04:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.