2

I have had a custom console command running fine for several months now which sent out reminder emails to users when there accounts are about to expire.

After the latest Craft update (I believe) it stopped working. Here is the error:

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054
Unknown column 'users.locked' in 'field list'
exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.locked' in 'field list'' in CDbCommand.php:543

The lines of code from the plugin service which cause the error are:

$user_criteria = craft()->elements->getCriteria(ElementType::User);

$user_criteria->userExpiryDate = date('Y-m-d',strtotime("+7 days"));

$users = $user_criteria->find();

Basically it fails when running the find() method.

Strangely I haven't managed to replicate the error on my local machine.

Does anyone have any idea what might be causing this?

  • Do you have a 'locked' column in your craft_users table? That table's schema changed within the last several months. Maybe your database and your code are out of sync? – Brad Bell Jan 16 '15 at 17:53
  • Hi Brad, I've just checked the table and there is no locked column. What would be the best way to fix this problem? – Dave Coggins Jan 19 '15 at 10:01
  • Check the schemaVersion and build in your craft/app/Info.php and file and compare that to you the schemaVersion and build in the craft_info table in the database. If those don't match then your database schema is out of sync with the code you're running. – Brad Bell Jan 19 '15 at 18:50
  • On the live site in the Info.php it is on 2.3.1 but on the database it is 2.1.2. Somebody else applied the update on the live site without my knowledge so I'm not sure whether it was successful. When I backed up the live database and imported it to my local server the schemas matched (both on 2.3.1) which I can't seem to explain. Any suggestions on how to resolve this issue? – Dave Coggins Jan 20 '15 at 3:04
  • What's the build number in Info.php and the database? – Brad Bell Jan 20 '15 at 17:55
0

This ended up being a case of looking at the wrong database. The version/build/schema numbers for the correct database were all in sync.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.