From ac7fd5abd4094230c9f1068f31e4286c1f399a40 Mon Sep 17 00:00:00 2001 From: Lens0021 / Leslie Date: Sat, 21 Sep 2024 14:47:42 +0900 Subject: [PATCH 1/2] Replace a raw query with expr() --- includes/HookHandlers/SpamEmail.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/HookHandlers/SpamEmail.php b/includes/HookHandlers/SpamEmail.php index 8acb64f..39dc68e 100644 --- a/includes/HookHandlers/SpamEmail.php +++ b/includes/HookHandlers/SpamEmail.php @@ -63,15 +63,16 @@ public function onIsValidEmailAddr( $addr, &$result ) { } // Check email addresses of block users + $dbr = $this->loadBalancer->getConnection( DB_REPLICA ); $emails = array_filter( array_unique( array_map( - static function ( $block ) { + static function ( $block ) use ( $dbr ) { $id = $block->getBlocker(); if ( $id ) { return User::newFromIdentity( $id )->getEmail(); } return null; }, - $this->databaseBlockStore->newListFromConds( [ 'bt_user IS NOT NULL' ] ) + $this->databaseBlockStore->newListFromConds( [ $dbr->expr( 'bt_user', '!=', null ) ] ) ) ) ); if ( in_array( $addr, $emails ) ) { return false; From 518039759760d831b68b21ace86253c8f5c6acd6 Mon Sep 17 00:00:00 2001 From: Lens0021 / Leslie Date: Sat, 21 Sep 2024 15:11:46 +0900 Subject: [PATCH 2/2] Update SpamEmail.php --- includes/HookHandlers/SpamEmail.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/HookHandlers/SpamEmail.php b/includes/HookHandlers/SpamEmail.php index 39dc68e..30fe63e 100644 --- a/includes/HookHandlers/SpamEmail.php +++ b/includes/HookHandlers/SpamEmail.php @@ -63,16 +63,15 @@ public function onIsValidEmailAddr( $addr, &$result ) { } // Check email addresses of block users - $dbr = $this->loadBalancer->getConnection( DB_REPLICA ); $emails = array_filter( array_unique( array_map( - static function ( $block ) use ( $dbr ) { + static function ( $block ) { $id = $block->getBlocker(); if ( $id ) { return User::newFromIdentity( $id )->getEmail(); } return null; }, - $this->databaseBlockStore->newListFromConds( [ $dbr->expr( 'bt_user', '!=', null ) ] ) + $this->databaseBlockStore->newListFromConds( [] ) ) ) ); if ( in_array( $addr, $emails ) ) { return false;