mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleBlacklist
synced 2024-11-27 15:30:48 +00:00
Make use of ?? operators in TitleBlacklist::isBlacklisted
I think this makes the code quite a bit more readable. The behavior should be the same as before. Change-Id: I9c4a52b2c6908f023b3f55e27dcd2b1e5bef6c31
This commit is contained in:
parent
52d708f9b3
commit
9174731169
|
@ -215,29 +215,26 @@ class TitleBlacklist {
|
|||
public function isBlacklisted( $title, $action = 'edit' ) {
|
||||
if ( !( $title instanceof Title ) ) {
|
||||
$title = Title::newFromText( $title );
|
||||
if ( !( $title instanceof Title ) ) {
|
||||
if ( !$title ) {
|
||||
// The fact that the page name is invalid will stop whatever
|
||||
// action is going through. No sense in doing more work here.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$blacklist = $this->getBlacklist();
|
||||
$autoconfirmedItem = false;
|
||||
foreach ( $blacklist as $item ) {
|
||||
|
||||
$autoconfirmedItem = null;
|
||||
foreach ( $this->getBlacklist() as $item ) {
|
||||
if ( $item->matches( $title->getFullText(), $action ) ) {
|
||||
if ( $this->isWhitelisted( $title, $action ) ) {
|
||||
return false;
|
||||
}
|
||||
$params = $item->getParams();
|
||||
if ( !isset( $params['autoconfirmed'] ) ) {
|
||||
if ( !isset( $item->getParams()['autoconfirmed'] ) ) {
|
||||
return $item;
|
||||
}
|
||||
if ( !$autoconfirmedItem ) {
|
||||
$autoconfirmedItem = $item;
|
||||
}
|
||||
$autoconfirmedItem ??= $item;
|
||||
}
|
||||
}
|
||||
return $autoconfirmedItem;
|
||||
return $autoconfirmedItem ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue