Hi,

If I have a role that is allowed to edit all other roles I'm seeing this error:

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in People (administerusersbyrole)[administerusersbyrole_people]: SQLSTATE[42000]: Syntax error or access violation: 1064 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 ')
               WHERE (( (users_field_data.default_langcode = '1') AND (users_field_data.uid !' at line 2: SELECT COUNT(*) AS expression
               FROM
               (SELECT 1 AS expression
               FROM
               {users_field_data} users_field_data
               INNER JOIN {user__roles} ur ON ur.entity_id=users_field_data.uid
               LEFT OUTER JOIN {user__roles} ur_2 ON ur.entity_id=users_field_data.uid AND ur.roles_target_id IN ()
               WHERE (( (users_field_data.default_langcode = :db_condition_placeholder_0) AND (users_field_data.uid != :db_condition_placeholder_1) ))AND (users_field_data.uid  :db_condition_placeholder_2) AND (ur_2.entity_id IS NULL )
               ) subquery; Array
               (
                   [:db_condition_placeholder_0] => 1
                   [:db_condition_placeholder_1] => 0
                   [:db_condition_placeholder_2] => 1
               )
                in Drupal\views\Plugin\views\query\Sql->execute() (line 1488 of /var/www/sites/smg/smg3/docroot/core/modules/views/src/Plugin/views/query/Sql.php).

If I exclude one role, the error goes away.

In administerusersbyrole_query_administerusersbyrole_edit_access_alter(), because there is nothing in $exclude, the query isn't valid.

If I add

    if (!$exclude){
      return;
    }

at line 132, there's no error and the user list looks fine. (or I could wrap the last part in if($exclude)).

I don't know enough about the module to know if that's correct in all situations.

thanks.

Comments

Andy Tawse created an issue. See original summary.

adamps’s picture

Priority: Normal » Minor

Sounds like it is a bug, thanks for the report.

However the circumstances needed to hit the bug are unusual!

  • AUBR never offers a permission to manage the admin role. So can I deduce that you have no admin role on your site (see /admin/config/people/accounts)?
  • If a sub-admin can admin all other users, then they effectively have administer_users permission and it could be simpler and clearer to assign that single permission rather than setting roles one by one.

Hence marking as minor priority, but I will try to fix at some stage. I think your proposed fix is correct.

andy tawse’s picture

Hi,

Yes, we have no admin role.

And actually, I found that "administer users" was more appropriate later on as the work developed and the bug no longer affected me.

Agree that it's therefore low priority!

thanks

  • AdamPS committed 928c0f6 on 8.x-2.x
    Issue #2849563 by shawn_smiley, AdamPS: Errors on user overview page...
adamps’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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