From 91747311690688e7f063dfa804f104fcf362e56f Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Fri, 16 Aug 2024 15:58:10 +0200 Subject: [PATCH] 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 --- includes/TitleBlacklist.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/includes/TitleBlacklist.php b/includes/TitleBlacklist.php index 30f14eb0..8af7f5af 100644 --- a/includes/TitleBlacklist.php +++ b/includes/TitleBlacklist.php @@ -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; } /**