From fc9a494f29a77665d446552e172906cba37c9d77 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 16 Feb 2024 10:41:12 +1100 Subject: [PATCH] Use Database::expr() Bug: T350980 Change-Id: I369778002a880f1547940a097d96e55bcba9a08d --- includes/LoginNotify.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/LoginNotify.php b/includes/LoginNotify.php index ce862a1..bddcaf3 100644 --- a/includes/LoginNotify.php +++ b/includes/LoginNotify.php @@ -30,9 +30,11 @@ use UnexpectedValueException; use Wikimedia\Assert\Assert; use Wikimedia\IPUtils; use Wikimedia\Rdbms\IDatabase; +use Wikimedia\Rdbms\IExpression; use Wikimedia\Rdbms\IMaintainableDatabase; use Wikimedia\Rdbms\IReadableDatabase; use Wikimedia\Rdbms\LBFactory; +use Wikimedia\Rdbms\LikeValue; /** * Handle sending notifications on login from unknown source. @@ -315,7 +317,7 @@ class LoginNotify implements LoggerAwareInterface { ->where( [ 'lsn_user' => $centralUserId, 'lsn_subnet' => $hash, - 'lsn_time_bucket >= ' . $dbr->addQuotes( $this->getMinBucket() ) + $dbr->expr( 'lsn_time_bucket', '>=', $this->getMinBucket() ) ] ) ->caller( __METHOD__ ) ->fetchField(); @@ -595,10 +597,10 @@ class LoginNotify implements LoggerAwareInterface { ->join( 'actor', null, 'actor_id = cuc_actor' ) ->where( [ 'actor_user' => $userId, - 'cuc_ip ' . $dbr->buildLike( + $dbr->expr( 'cuc_ip', IExpression::LIKE, new LikeValue( $ipFragment, $dbr->anyString() - ) + ) ) ] ) ->caller( __METHOD__ ) ->fetchField(); @@ -830,9 +832,9 @@ class LoginNotify implements LoggerAwareInterface { $dbw->newDeleteQueryBuilder() ->delete( 'loginnotify_seen_net' ) ->where( [ - 'lsn_id >= ' . $dbw->addQuotes( $minId ), - 'lsn_id < ' . $dbw->addQuotes( $maxId ), - 'lsn_time_bucket < ' . $dbw->addQuotes( $this->getMinBucket() ) + $dbw->expr( 'lsn_id', '>=', $minId ), + $dbw->expr( 'lsn_id', '<', $maxId ), + $dbw->expr( 'lsn_time_bucket', '<', $this->getMinBucket() ) ] ) ->caller( __METHOD__ ) ->execute();