It fails when drupal use tables with prefix with this error
Error messagePDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database_name.aes_passwords' doesn't exist: SELECT uid FROM aes_passwords WHERE uid = :uid; Array ( [:uid] => 1 ) in aes_password_exists() (line 480 of /home/merchiac/public_html/crmiac.com/test/sites/all/modules/aes/aes.module).
The website encountered an unexpected error. Please try again later.
line 480 from aes.module
$result = db_query("SELECT uid FROM aes_passwords WHERE uid = :uid", array(':uid' => $uid));
I changed it to
$result = db_query("SELECT uid FROM {aes_passwords} WHERE uid = :uid", array(':uid' => $uid));
and it works. It seems, there is same problem in line 492
$result = db_query("SELECT pass FROM aes_passwords WHERE uid = :uid", array(':uid' => $uid));
Comments
Comment #1
bobbyaldol CreditAttribution: bobbyaldol commented@sergei_brill: 'database_name.aes_passwords' doesn't exist
The database would be created during installation of the module as specified in aes_schema in aes.install. There shouldnt be a problem unless you have deleted it by chance.
Could you describe more explicitly how the error occurred so that I can generate it on mine.
Comment #2
sergei_brill CreditAttribution: sergei_brill commentedYes, table aes_passwords was created. But my settings.php have next option for database:
So, when in code is
$result = db_query("SELECT uid FROM aes_passwords WHERE uid = :uid", array(':uid' => $uid));
error occur.
When in code is
$result = db_query("SELECT uid FROM {aes_passwords} WHERE uid = :uid", array(':uid' => $uid));
it works without errors.
I didn't test for tables without prefix. I think drupal search for table name in $query using symbols {} and replaces table_name to the prefix_table_name. I compared your code with another modules and core code. There is {table_name} in query.
Comment #3
kacey CreditAttribution: kacey commentedI had to make the changes suggested by sergei_brill in order to be able to log into my web site at all. Without this suggestion my site would be inaccessible. I have backups of course, but I appreciate avoiding the hassle.
Is this change causing other issues? The database and the aes_passwords table exists and I have made no changes to it. Is there something I am doing wrong?
Thanks so much for your help!
Comment #4
bobbyaldol CreditAttribution: bobbyaldol commentedThe database queries need {} for the table name if it is prefixed. That might be the reason why it worked on mine but not on yours , so neglected it till now. I will make the necessary changes ASAP.
Thanks
Comment #5
bobbyaldol CreditAttribution: bobbyaldol commentedThis has been taken care of in the dev version 7.x-1.x-dev of the module and will be effective from the next release.