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
This commit is contained in:
Umherirrender 2024-10-27 13:20:18 +01:00
parent 63de22357d
commit 6252afcac7

View file

@ -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;
}