Skip to content

Commit

Permalink
Drop backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed May 26, 2024
1 parent 0d89531 commit 6267b67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license-name": "AGPL-3.0-or-later",
"type": "specialpage",
"requires": {
"MediaWiki": ">= 1.35.0",
"MediaWiki": ">= 1.42.0",
"extensions": {
"CategoryTree": "*"
}
Expand Down
33 changes: 4 additions & 29 deletions includes/HookHandlers/SpamEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,35 +63,10 @@ public function onIsValidEmailAddr( $addr, &$result ) {
}

// Check email addresses of block users
if ( version_compare( '1.42', MW_VERSION, '<=' ) ) {
$emails = array_filter( array_unique( array_map(
static fn( $block ) => User::newFromIdentity( $block->getBlocker() )->getEmail(),
$this->databaseBlockStore->newListFromConds( [ 'bt_user IS NOT NULL' ] )
) ) );
} else {
$loadBalancer = $this->loadBalancer;
$emails = $this->wanCache->getWithSetCallback(
$this->wanCache->makeKey( 'unified-femiwiki-extension-blocked-email' ),
WANObjectCache::TTL_HOUR,
static function ( $old, &$ttl, array &$setOpts ) use ( $loadBalancer ) {
$dbr = $loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
return $dbr->newSelectQueryBuilder()
->distinct()
->fields( [ 'user_email' ] )
->tables( [ 'ipblocks' ] )
->join( 'user', 'user_id = ipb_user' )
->conds( [
'ipb_user IS NOT NULL',
'user_email != ' . $dbr->addQuotes( '' ),
'ipb_expiry > ' . $dbr->addQuotes( $dbr->timestamp() ),
] )
->fetchFieldValues();
}
);
if ( !is_array( $emails ) ) {
$emails = [];
}
}
$emails = array_filter( array_unique( array_map(
static fn( $block ) => User::newFromIdentity( $block->getBlocker() )->getEmail(),
$this->databaseBlockStore->newListFromConds( [ 'bt_user IS NOT NULL' ] )
) ) );
if ( in_array( $addr, $emails ) ) {
return false;
}
Expand Down

0 comments on commit 6267b67

Please sign in to comment.