I am getting this error that is preventing cron.php from completing when the Automember module is enabled:

Fatal error: Unknown column 'status' in 'where clause' query: SELECT DISTINCT(uid) AS uid FROM users_roles WHERE rid IN (2) AND status=1 AND uid>0 in /home/code0/domains/code0range.net/public_html/includes/database.mysql.inc on line 66

I have tracked the possible cause to around line 521 of the module:

      #
      # Compile list of users with required role(s) or a list of all users
      #
      $users_with_required_roles = array();
      $all_users = array();
      if ($data->enable_limit_required_roles && $data->limit_required_roles) {
        switch ($data->limit_required_roles_any_or_all) {
          case 'any':
            $result = db_query('SELECT DISTINCT(uid) AS uid FROM {users_roles} WHERE rid IN (%s) AND status=1 AND uid>0', 
                                implode(',', $data->limit_required_roles));
            break;

It looks like the query is looking for a column called status in the 'user_roles' table, but that column does not exist there. Perhaps the query is looking for the status column in the 'users' table?

Comments

njivy’s picture

I corrected the SQL query and tidied up another adjacent query.

I also replaced the call to check_query() with db_escape_string() as required for compatibility with pre-4.6 Drupal. If you're running 4.5.x, check line 530 and revert it back to check_query().

Cheers,
Nic

grohk’s picture

Thanks again njivy! Everything is working well for now. Also, I sent you a donation via njivy.org to thank you for your hard work on the rewrite. It is extremely nice and integrates well with HEAD.

Anonymous’s picture