PDOException: SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'p.rid': SELECT p.rid.* FROM {role} r {} WHERE (r.name = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => authenticated user ) in function _password_policy_load_active_policy()
The problem is that select doesn't include table with alias 'p'. p.rid should be replaced with r.rid.
// If the role is a name, not an ID, replace with the ID.
for ($i = 0; $i < count($roles); $i++) {
if (!is_numeric($roles[$i])) {
$row = db_select('role', 'r', array('target' => 'slave'))
->fields('p.rid')
->condition('r.name', $roles[$i])
->execute()
->fetchAssoc();
if (!empty($row['rid'])) {
$roles[$i] = $row['rid'];
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | password_policy-7.x-1.x-fix_unknown_table_error-3032886-7.patch | 541 bytes | aohrvetpv |
| #2 | password_policy-table-not-exist-3032886-02.patch | 625 bytes | fertant |
Comments
Comment #2
fertant commentedFix included
Comment #3
fertant commentedComment #5
aohrvetpv commentedfertant, thanks for reporting this bug. How can you cause the error to occur? I am trying to determine the impact of this bug. This code has been present since 2010 but no one has reported a problem before.
I'm not sure why your patch is not applying. You could try creating it per the instructions here:
https://www.drupal.org/project/password_policy/git-instructions
Comment #6
aohrvetpv commentedfertant, also, if it is possible to report: What PHP version and database system are you using?
Comment #7
aohrvetpv commentedPatch with same changes as in #2
Comment #9
aohrvetpv commentedThis seems like an obvious bug fix, so went ahead and committed. Thanks.
Would still like answers to my questions in #5 and #6 if possible. I would like to determine the severity/impact of this bug to decide how soon a new release is needed.
Comment #10
fertant commentedPHP version on server 7.0.23-1, on local env 7.2.0. Database MySQL 5.7.
Bug reproduced once I validate password in my form validate hook executing your function _password_policy_constraint_validate($password, $account) and as role I am passing it with names, not rid $account->roles = array("authenticated user" => "authenticated user");