Use Database::expr()

Bug: T350980
Change-Id: I369778002a880f1547940a097d96e55bcba9a08d
This commit is contained in:
Tim Starling 2024-02-16 10:41:12 +11:00
parent e845943d60
commit fc9a494f29

View file

@ -30,9 +30,11 @@ use UnexpectedValueException;
use Wikimedia\Assert\Assert; use Wikimedia\Assert\Assert;
use Wikimedia\IPUtils; use Wikimedia\IPUtils;
use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\IExpression;
use Wikimedia\Rdbms\IMaintainableDatabase; use Wikimedia\Rdbms\IMaintainableDatabase;
use Wikimedia\Rdbms\IReadableDatabase; use Wikimedia\Rdbms\IReadableDatabase;
use Wikimedia\Rdbms\LBFactory; use Wikimedia\Rdbms\LBFactory;
use Wikimedia\Rdbms\LikeValue;
/** /**
* Handle sending notifications on login from unknown source. * Handle sending notifications on login from unknown source.
@ -315,7 +317,7 @@ class LoginNotify implements LoggerAwareInterface {
->where( [ ->where( [
'lsn_user' => $centralUserId, 'lsn_user' => $centralUserId,
'lsn_subnet' => $hash, 'lsn_subnet' => $hash,
'lsn_time_bucket >= ' . $dbr->addQuotes( $this->getMinBucket() ) $dbr->expr( 'lsn_time_bucket', '>=', $this->getMinBucket() )
] ) ] )
->caller( __METHOD__ ) ->caller( __METHOD__ )
->fetchField(); ->fetchField();
@ -595,10 +597,10 @@ class LoginNotify implements LoggerAwareInterface {
->join( 'actor', null, 'actor_id = cuc_actor' ) ->join( 'actor', null, 'actor_id = cuc_actor' )
->where( [ ->where( [
'actor_user' => $userId, 'actor_user' => $userId,
'cuc_ip ' . $dbr->buildLike( $dbr->expr( 'cuc_ip', IExpression::LIKE, new LikeValue(
$ipFragment, $ipFragment,
$dbr->anyString() $dbr->anyString()
) ) )
] ) ] )
->caller( __METHOD__ ) ->caller( __METHOD__ )
->fetchField(); ->fetchField();
@ -830,9 +832,9 @@ class LoginNotify implements LoggerAwareInterface {
$dbw->newDeleteQueryBuilder() $dbw->newDeleteQueryBuilder()
->delete( 'loginnotify_seen_net' ) ->delete( 'loginnotify_seen_net' )
->where( [ ->where( [
'lsn_id >= ' . $dbw->addQuotes( $minId ), $dbw->expr( 'lsn_id', '>=', $minId ),
'lsn_id < ' . $dbw->addQuotes( $maxId ), $dbw->expr( 'lsn_id', '<', $maxId ),
'lsn_time_bucket < ' . $dbw->addQuotes( $this->getMinBucket() ) $dbw->expr( 'lsn_time_bucket', '<', $this->getMinBucket() )
] ) ] )
->caller( __METHOD__ ) ->caller( __METHOD__ )
->execute(); ->execute();