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

bobbyaldol’s picture

@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.

sergei_brill’s picture

Yes, table aes_passwords was created. But my settings.php have next option for database:

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'db_name',
      'username' => 'username',
      'password' => '12345',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => 'prefix_', //not empty.
    ),
  ),
);

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.

kacey’s picture

I 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!

bobbyaldol’s picture

Assigned: sergei_brill » bobbyaldol

The 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

bobbyaldol’s picture

Status: Active » Fixed

This 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.

Status: Fixed » Closed (fixed)

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