From 6252afcac77120adc4eb46c7e0950bd64eb10835 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sun, 27 Oct 2024 13:20:18 +0100 Subject: [PATCH] Simplify code by replacing isset() with falsy check Conditional set of variable is not easy to read. Instead set the variable to null before try/catch Reported by a new phan plugin (2efea9f989) This bypass a false positive from phan (T378271) Change-Id: I037efe8465747b8c915405f38546fc1ea4405a03 --- includes/View/AbuseFilterViewHistory.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/View/AbuseFilterViewHistory.php b/includes/View/AbuseFilterViewHistory.php index 75d009d7a..9eec99363 100644 --- a/includes/View/AbuseFilterViewHistory.php +++ b/includes/View/AbuseFilterViewHistory.php @@ -74,16 +74,17 @@ class AbuseFilterViewHistory extends AbuseFilterView { $canViewProtectedVars = $this->afPermManager->canViewProtectedVariables( $this->getAuthority() ); if ( $filter ) { + $filterObj = null; try { $filterObj = $this->filterLookup->getFilter( $filter, false ); } catch ( FilterNotFoundException $_ ) { $filter = null; } - if ( isset( $filterObj ) && $filterObj->isHidden() && !$canViewPrivate ) { + if ( $filterObj && $filterObj->isHidden() && !$canViewPrivate ) { $out->addWikiMsg( 'abusefilter-history-error-hidden' ); return; } - if ( isset( $filterObj ) && $filterObj->isProtected() && !$canViewProtectedVars ) { + if ( $filterObj && $filterObj->isProtected() && !$canViewProtectedVars ) { $out->addWikiMsg( 'abusefilter-history-error-protected' ); return; }