Hi there,

when printing a view, as described here (#1 - user-type view)...

-> How to setup a "Who's bookmarked this" tab

... I get these errors:

warning: array_fill() [function.array-fill]: Number of elements must be positive in /includes/database.inc on line 241.
warning: implode() [function.implode]: Bad arguments. in /includes/database.inc on line 241.
warning: array_keys() [function.array-keys]: The first argument should be an array in /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 /user/user.module on line 502.

Is it a Flag's or Views' issue?

Tia,
szy.

Comments

szy’s picture

Project: Drupal core » Flag
Version: 6.9 » 6.x-1.x-dev
Component: user.module » Code
Issue tags: -views, -user, -Flag

This is my view, causing the errors.

$view = new view;
$view->name = 'My_Name';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'users';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'flag_user_content_rel' => array(
    'label' => 'user flagged content',
    'required' => 1,
    'flag' => 'interesting',
    'id' => 'flag_user_content_rel',
    'table' => 'users',
    'field' => 'flag_user_content_rel',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'name' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
  ),
  'timestamp' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'date_format' => 'time ago',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'timestamp',
    'table' => 'flag_content',
    'field' => 'timestamp',
    'relationship' => 'flag_user_content_rel',
  ),
  'picture' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'picture',
    'table' => 'users',
    'field' => 'picture',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'timestamp' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'timestamp',
    'table' => 'flag_content',
    'field' => 'timestamp',
    'relationship' => 'flag_user_content_rel',
  ),
));
$handler->override_option('arguments', array(
  'content_id' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Wszystkie',
    'title' => '',
    'default_argument_type' => 'node',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'content_id',
    'table' => 'flag_content',
    'field' => 'content_id',
    'relationship' => 'flag_user_content_rel',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'validate_argument_node_type' => array(
      'my' => 0,
      'custom' => 0,
      'node' => 0,
      'types' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '34' => 0,
      '33' => 0,
      '35' => 0,
      '3' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => '',
  'type' => 'ul',
));

Szy.

szy’s picture

Now I see that errors disappear when I remove user's picture field. Hm?

Szy.

szy’s picture

Project: Flag » Drupal core
Version: 6.x-1.x-dev » 6.9
Component: Code » user.module
Issue tags: +views, +user, +Flag

Hello,

I'm moving this issue from Flag's queue to Drupal User's issues. I assume it's
a user.module's behaviour problem - feel free to move it if I'm wrong...

Tia for your help,
Szy.

szy’s picture

Issue tags: +views, +user, +Flag
szy’s picture

I still get this error using code from #368644: Get users who flagged a node, first comment.

I'm moving this issue back to Flag's queue.

Szy.

quicksketch’s picture

I can import your view and it seems to work fine. At least I can't reproduce the problem that you're describing. This may be similar to your other issue, #380914: Get both anonymous and logged in users who flagged a node..., which I've looked a little bit into also. The problem with both this and the other issue may be that the Anonymous user is not in the database. Since there is no anonymous user in the database (in the "users" table) the user information can never be loaded.

The segment of code your describing comes from the user_access() function. Which I'm guessing that something is trying to check permissions against an anonymous user. However, since the anonymous user isn't in the database there's no way that Drupal can load it or check permissions against it.

It seems that this will be a further limitation of our anonymous flagging: we can't list them at all. However, that doesn't mean that Flag shouldn't automatically prevent such errors from happening, even if we can't list anonymous users. However, the trouble is that I can't get the same error you are getting.

mooffie’s picture

Szymon, you should find out why user_access() is called in the first place. One way to do this is to add the following before line 502:

if (!isset($account->roles)) {
  drupal_set_message('<pre>' . print_r(debug_backtrace(), 1) . '</pre>');
}

(The code may have typos.)

mitchell’s picture

Component: Code » Miscellaneous
Status: Active » Postponed (maintainer needs more info)
danfinney’s picture

I received the same error message after approving a spammy looking comment. (I moderate comments.)

rajo’s picture

I received this message after enabling Gravatar module :(

daengo’s picture

I get this same error when I try to enable the path module.

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 /THE_PATH/modules/user/user.module on line 502.

quicksketch’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I'm closing this issue since it's not an actual bug in Flag module (unless you apply the unfinished patch in #271582: Allow anonymous users to flag content). Please do not reopen this issue unless experiencing the issue with an official release of Flag module.

Nathan1979’s picture

I had the same error but fixed it:

I found the cause within the user.module @ function user_access($string, $account = NULL, $reset = FALSE) line 482.

This function recieved a second agument ($account) as also a permission string instead of a user object. Therefor the user roles could not be found, resulting in this error.

Tracing down the caller of this script i found in includes/menu.inc @ function _menu_check_access(&$item, $map) line 436
that this script was called with 2 arguments cause $item['access_arguments'] hold 2 arguments, should be 1!! (unles the second argument is a userobject).

Solution:

use print_r to print $map and $arguments. now notice that somewhere $arguments holds 2 permissions within the array. The $map corresponding to this $arguments tells us the routerpath.

The actual problem is situated within the 'menu_router' table, field access_arguments. Find the correct routerpath and edit the serialized array for field access_arguments so it holds only 1 key=>value.

This worked for me, hope it helps you to fix your problems...

kakajoe’s picture

hi nathan...would you care to give us a snippet for you trick?? so a newbie like me can understand...thanks

James Marks’s picture

Seems like adding a test in user_access to make sure that $account->roles is an array before treating it as an array might be a good idea (http://api.drupal.org/api/function/user_access/6#comment-1513), not as a core-hack but as a core improvement. Otherwise, it will be necessary to track down every call that provides incompatible parameters (and there seem to be a number of them in various contrib modules).

scuba_fly’s picture

Issue tags: +access, +user access

Old topic, but it helped me out :)

Nathan1979 said something about access_arguments having 2 arguments
that was exacly the case in my code.

I had a hook_menu implementation:

function module_menu() {
$items = array();

$items['click_stats'] = array(
            'title' => t('Reports'),
            'description' => t('Show the clicks reports'),
            'page callback' => 'module_clickstats',
            'access callback' => 'user_access',
            'access arguments' => array('access click stats', 'access all click stats'),
            'type' => MENU_NORMAL_ITEM,
            'menu_name' => 'primary-links',
    );

}

changed the line:

 'access arguments' => array('access click stats', 'access all click stats'),

to:

 'access arguments' => array('access click stats'),

And now it works fine. Hope this helps anyone who was googling for this as i was.