On "Editorial assignments by editor" screen, I can see that 2 editors are linked to a section, and when I click on the link, only one user is there. It's because the user has 2 roles that are both affected to the section, so
$count = db_query("SELECT COUNT(wau.uid) FROM {workbench_access_user} wau
INNER JOIN {users_roles} ur ON wau.uid = ur.uid
WHERE wau.access_scheme = :access_scheme AND wau.access_id = :access_id
AND ur.rid IN (:rids)",
array(':access_scheme' => $active['access_scheme']['access_type'], ':access_id' => $access_id, ':rids' => array_keys($roles)))->fetchField();
(in workbench_access_editors()) returns "2" because of the user_roles JOIN.
I'd put a DISTINCT immediately before wau.id, but I forgot if it's totally cross-database or not...
Comments
Comment #1
agentrickardGood catch.
Comment #2
agentrickardCommitted.
(And yes, DISTINCT is fine in db_query()).