Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If the php error level is set to display notices (which is my case in my dev environment), there can be a php notice if trying to masquerade with a username with the Alternate login module enabled.
The PHP Notice says :
Notice : Trying to get property of non-object dans masquerade_block_1_validate()
And it refers to the line 626 of masquerade.module :
$alt_login = db_query("SELECT u.name FROM {users} u INNER JOIN {alt_login} al ON u.uid = al.uid WHERE al.alt_login = :alt_login", array(
':alt_login' => $name
))->fetchObject();
if ($alt_login->name) {
If nothing returns from the db_query, the fetchObject method returns false, and the call to the property name of a boolean generates a PHP notice.
You just have to test for the return value, as followed :
if($alt_login && $alt_login->name) {
Here is a small patch.
Comment | File | Size | Author |
---|---|---|---|
masquerade_alt_login.patch | 588 bytes | iannakin | |
Comments
Comment #1
deekayen CreditAttribution: deekayen commentedcommitted a fix using isset() instead