mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Performance issues with BasicAuth and LoginAttempts
Two functions interact with the LoginAttempt object which when used in conjunction with BasicAuth result in significant performance degradation over time, as the LoginAttempts Table fills. This fix adds an index to the lookup column EmailHashed and removes the Email filter part of getByEmail() so it can use the index resulting in a much faster query. For more information see https://github.com/silverstripe/silverstripe-framework/issues/8389
This commit is contained in:
parent
270aba4007
commit
c269a987d5
@ -46,6 +46,10 @@ class LoginAttempt extends DataObject
|
||||
'Member' => Member::class, // only linked if the member actually exists
|
||||
);
|
||||
|
||||
private static $indexes = array(
|
||||
"EmailHashed" => true
|
||||
);
|
||||
|
||||
private static $table_name = "LoginAttempt";
|
||||
|
||||
/**
|
||||
@ -86,7 +90,6 @@ class LoginAttempt extends DataObject
|
||||
public static function getByEmail($email)
|
||||
{
|
||||
return static::get()->filterAny(array(
|
||||
'Email' => $email,
|
||||
'EmailHashed' => sha1($email),
|
||||
));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user