The bug happens when cancel user account from Home > Administration > People > Update user account : "Cancel the selected user accounts", if select cancellation options unpublishing or deleting the account content, but account does not have any content.
When cancelling these accounts
- Disable the account and unpublish its content.
- Delete the account and make its content belong to the Ivushka user.
- Delete the account and its content.
It posts the error message:
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /drupal/batch?render=overlay&id=619&op=do StatusText: Service unavailable (with message) ResponseText: Recoverable fatal error: Argument 2 passed to db_query() must be an array, null given, called in /sites/all/modules/tokenauth/tokenauth.module on line 186 and defined in db_query() (line 2313 of /includes/database/database.inc).
The bug is caused by empty content, returning NULL pointer in the tokenauth.module on line 186:
/**
* Implements hook_user_delete().
*/
function tokenauth_user_delete(&$edit, &$account, $category = NULL) {
$sql = 'DELETE FROM {tokenauth_tokens} WHERE uid = %d';
db_query($sql, $account->uid);
}
It is fixed by adding the condition operator:
/**
* Implements hook_user_delete().
*/
function tokenauth_user_delete(&$edit, &$account, $category = NULL) {
$sql = 'DELETE FROM {tokenauth_tokens} WHERE uid = %d';
if ( $account->uid != NULL)
db_query($sql, $account->uid);
}
Comments
Comment #1
elBradford commentedThis worked for me. A .patch would be nice, but this is such a simple fix I think the maintainer can roll this in the new dev.
Comment #2
andrewbenkard commentedWorked for me too. Thanks sergeytru.
Comment #3
Grayside commentedActually, this is an upgrade path problem, and in either case the code is not doing anything except failing whenever it is run. See hook_user_delete().
Our fix should instead be:
Checking whether a hook has indeed passed the object it has deleted is a warning sign. What could you possibly do in an implementation of the hook if that data were missing? I'll attempt to get this into -dev later tonight.
Comment #4
Grayside commentedhttp://drupalcode.org/project/tokenauth.git/commit/2db0dda
Comment #5
justdave commentedMust not have been included in a release yet, since I just tripped this bug and my update report says I'm up-to-date. Applied the patch manually and can verify it works though.
Comment #6
David4514 commentedStill failing after the patch. However, instead of null, I'm failing because argument 2 is a string. Argument 2 of db_query must be an array.
Recoverable fatal error: Argument 2 passed to db_query() must be an array, string given, called in /var/www/taiwv2/www/Secure_Server/sites/all/modules/contrib/tokenauth/tokenauth.module on line 186 and defined in db_query() (line 2313 of /var/www/taiwv2/www/Secure_Server/includes/database/database.inc).
The preferred method is to use named placeholders with db_query. Argument 2 of db_query should be an associative array in this case.
While named placeholders are not required, the second argument of db_query must always be an array.
Comment #7
Grayside commentedThanks @David4514! That makes sense but I will have to circle back another time to confirm it works.
Comment #8
dalinPatch attached to make the change proposed by David4514.
Comment #9
Offlein commentedLooks good!
Comment #10
Grayside commentedComment #12
rrirower commentedI recently ran into this same problem. I can attest that the patch does work.