Use expression builder instead of raw sql

Change-Id: I6516951fc855dc32e864a3f21187b0a73daba7c8
This commit is contained in:
Umherirrender 2024-07-21 22:52:17 +02:00
parent df36e81d3b
commit 552f362cd5
3 changed files with 6 additions and 5 deletions

View file

@ -290,7 +290,7 @@ class EmailBatch {
$iterator->addConditions( [ 'eeb_user_id' => $this->mUser->getId() ] ); $iterator->addConditions( [ 'eeb_user_id' => $this->mUser->getId() ] );
if ( $this->lastEvent ) { if ( $this->lastEvent ) {
// There is a processed cutoff point // There is a processed cutoff point
$iterator->addConditions( [ 'eeb_event_id <= ' . (int)$this->lastEvent ] ); $iterator->addConditions( [ $dbr->expr( 'eeb_event_id', '<=', (int)$this->lastEvent ) ] );
} }
$iterator->setCaller( __METHOD__ ); $iterator->setCaller( __METHOD__ );

View file

@ -135,7 +135,8 @@ class NotificationMapper extends AbstractMapper {
array $titles = null, array $titles = null,
$dbSource = DB_REPLICA $dbSource = DB_REPLICA
) { ) {
$conds = [ 'notification_read_timestamp IS NOT NULL' ]; $dbr = $this->dbFactory->getEchoDb( $dbSource );
$conds = [ $dbr->expr( 'notification_read_timestamp', '!=', null ) ];
if ( $titles ) { if ( $titles ) {
$conds['event_page_id'] = $this->getIdsForTitles( $titles ); $conds['event_page_id'] = $this->getIdsForTitles( $titles );
if ( !$conds['event_page_id'] ) { if ( !$conds['event_page_id'] ) {
@ -366,7 +367,7 @@ class NotificationMapper extends AbstractMapper {
); );
$iterator->addConditions( [ $iterator->addConditions( [
'notification_user' => $userId, 'notification_user' => $userId,
'notification_event < ' . (int)$eventId $dbw->expr( 'notification_event', '<', (int)$eventId ),
] ); ] );
$iterator->setCaller( __METHOD__ ); $iterator->setCaller( __METHOD__ );

View file

@ -73,7 +73,7 @@ class RemoveOrphanedEvents extends LoggedUpdateMaintenance {
$iterator->addConditions( [ $iterator->addConditions( [
'notification_user' => null, 'notification_user' => null,
'eeb_user_id' => null, 'eeb_user_id' => null,
'event_id < ' . $maxId $dbr->expr( 'event_id', '<', $maxId ),
] ); ] );
$iterator->setCaller( __METHOD__ ); $iterator->setCaller( __METHOD__ );
@ -113,7 +113,7 @@ class RemoveOrphanedEvents extends LoggedUpdateMaintenance {
$iterator->addConditions( $iterator->addConditions(
[ [
'event_type' => null, 'event_type' => null,
'etp_event < ' . $maxId $dbr->expr( 'etp_event', '<', $maxId ),
] ]
); );
$iterator->addOptions( [ 'DISTINCT' ] ); $iterator->addOptions( [ 'DISTINCT' ] );