Collapse some nested if statements
authorReedy <reedy@wikimedia.org>
Fri, 29 Mar 2019 20:12:24 +0000 (20:12 +0000)
committerReedy <reedy@wikimedia.org>
Thu, 4 Apr 2019 19:02:22 +0000 (19:02 +0000)
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4

83 files changed:
includes/EditPage.php
includes/ForeignResourceManager.php
includes/GlobalFunctions.php
includes/Html.php
includes/MWGrants.php
includes/MediaWiki.php
includes/Message.php
includes/OutputPage.php
includes/PageProps.php
includes/PathRouter.php
includes/Revision/MainSlotRoleHandler.php
includes/Revision/RevisionStore.php
includes/Title.php
includes/Xml.php
includes/actions/CreditsAction.php
includes/api/ApiComparePages.php
includes/api/ApiHelp.php
includes/api/ApiMain.php
includes/api/ApiPageSet.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiQueryWatchlist.php
includes/auth/AuthManager.php
includes/auth/LocalPasswordPrimaryAuthenticationProvider.php
includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php
includes/cache/CacheHelper.php
includes/cache/HTMLFileCache.php
includes/cache/dependency/FileDependency.php
includes/cache/localisation/LCStoreCDB.php
includes/cache/localisation/LCStoreStaticArray.php
includes/collation/IcuCollation.php
includes/exception/MWExceptionRenderer.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/file/File.php
includes/filerepo/file/OldLocalFile.php
includes/htmlform/fields/HTMLNamespacesMultiselectField.php
includes/htmlform/fields/HTMLTitlesMultiselectField.php
includes/import/WikiImporter.php
includes/installer/PostgresInstaller.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteInstaller.php
includes/installer/WebInstaller.php
includes/installer/WebInstallerName.php
includes/installer/WebInstallerOptions.php
includes/installer/WebInstallerWelcome.php
includes/libs/MultiHttpClient.php
includes/libs/filebackend/FileBackendMultiWrite.php
includes/libs/mime/XmlTypeCheck.php
includes/libs/objectcache/WANObjectCache.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/libs/redis/RedisConnectionPool.php
includes/mail/EmailNotification.php
includes/media/BitmapHandler.php
includes/media/BitmapMetadataHandler.php
includes/media/SvgHandler.php
includes/page/Article.php
includes/parser/BlockLevelPass.php
includes/parser/Parser.php
includes/parser/Sanitizer.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderClientHtml.php
includes/skins/BaseTemplate.php
includes/skins/SkinTemplate.php
includes/specials/SpecialContributions.php
includes/specials/SpecialImport.php
includes/specials/SpecialSearch.php
includes/specials/SpecialUpload.php
includes/specials/SpecialWhatlinkshere.php
includes/specials/pagers/BlockListPager.php
includes/specials/pagers/ImageListPager.php
includes/tidy/RemexCompatFormatter.php
includes/title/MediaWikiTitleCodec.php
includes/upload/UploadBase.php
includes/upload/UploadStash.php
includes/user/User.php
includes/watcheditem/WatchedItemQueryService.php
tests/integration/includes/shell/FirejailCommandIntegrationTest.php
tests/phpunit/includes/Revision/RevisionStoreTest.php
tests/phpunit/structure/ApiStructureTest.php
tests/phpunit/structure/AutoLoaderStructureTest.php

index d8fef17..add48d9 100644 (file)
@@ -1214,149 +1214,147 @@ class EditPage {
                                $content = $this->getPreloadedContent( $preload, $params );
                        }
                // For existing pages, get text based on "undo" or section parameters.
-               } else {
-                       if ( $this->section != '' ) {
-                               // Get section edit text (returns $def_text for invalid sections)
-                               $orig = $this->getOriginalContent( $user );
-                               $content = $orig ? $orig->getSection( $this->section ) : null;
+               } elseif ( $this->section != '' ) {
+                       // Get section edit text (returns $def_text for invalid sections)
+                       $orig = $this->getOriginalContent( $user );
+                       $content = $orig ? $orig->getSection( $this->section ) : null;
 
-                               if ( !$content ) {
-                                       $content = $def_content;
-                               }
-                       } else {
-                               $undoafter = $request->getInt( 'undoafter' );
-                               $undo = $request->getInt( 'undo' );
-
-                               if ( $undo > 0 && $undoafter > 0 ) {
-                                       $undorev = Revision::newFromId( $undo );
-                                       $oldrev = Revision::newFromId( $undoafter );
-                                       $undoMsg = null;
-
-                                       # Sanity check, make sure it's the right page,
-                                       # the revisions exist and they were not deleted.
-                                       # Otherwise, $content will be left as-is.
-                                       if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
-                                               !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
-                                               !$oldrev->isDeleted( Revision::DELETED_TEXT )
+                       if ( !$content ) {
+                               $content = $def_content;
+                       }
+               } else {
+                       $undoafter = $request->getInt( 'undoafter' );
+                       $undo = $request->getInt( 'undo' );
+
+                       if ( $undo > 0 && $undoafter > 0 ) {
+                               $undorev = Revision::newFromId( $undo );
+                               $oldrev = Revision::newFromId( $undoafter );
+                               $undoMsg = null;
+
+                               # Sanity check, make sure it's the right page,
+                               # the revisions exist and they were not deleted.
+                               # Otherwise, $content will be left as-is.
+                               if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
+                                       !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
+                                       !$oldrev->isDeleted( Revision::DELETED_TEXT )
+                               ) {
+                                       if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev )
+                                               || !$this->isSupportedContentModel( $oldrev->getContentModel() )
                                        ) {
-                                               if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev )
-                                                       || !$this->isSupportedContentModel( $oldrev->getContentModel() )
-                                               ) {
-                                                       // Hack for undo while EditPage can't handle multi-slot editing
-                                                       $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [
-                                                               'action' => 'mcrundo',
-                                                               'undo' => $undo,
-                                                               'undoafter' => $undoafter,
-                                                       ] ) );
-                                                       return false;
-                                               } else {
-                                                       $content = $this->page->getUndoContent( $undorev, $oldrev );
+                                               // Hack for undo while EditPage can't handle multi-slot editing
+                                               $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [
+                                                       'action' => 'mcrundo',
+                                                       'undo' => $undo,
+                                                       'undoafter' => $undoafter,
+                                               ] ) );
+                                               return false;
+                                       } else {
+                                               $content = $this->page->getUndoContent( $undorev, $oldrev );
 
-                                                       if ( $content === false ) {
-                                                               # Warn the user that something went wrong
-                                                               $undoMsg = 'failure';
-                                                       }
+                                               if ( $content === false ) {
+                                                       # Warn the user that something went wrong
+                                                       $undoMsg = 'failure';
                                                }
+                                       }
 
-                                               if ( $undoMsg === null ) {
-                                                       $oldContent = $this->page->getContent( Revision::RAW );
-                                                       $popts = ParserOptions::newFromUserAndLang(
-                                                               $user, MediaWikiServices::getInstance()->getContentLanguage() );
-                                                       $newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
-                                                       if ( $newContent->getModel() !== $oldContent->getModel() ) {
-                                                               // The undo may change content
-                                                               // model if its reverting the top
-                                                               // edit. This can result in
-                                                               // mismatched content model/format.
-                                                               $this->contentModel = $newContent->getModel();
-                                                               $this->contentFormat = $oldrev->getContentFormat();
-                                                       }
+                                       if ( $undoMsg === null ) {
+                                               $oldContent = $this->page->getContent( Revision::RAW );
+                                               $popts = ParserOptions::newFromUserAndLang(
+                                                       $user, MediaWikiServices::getInstance()->getContentLanguage() );
+                                               $newContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
+                                               if ( $newContent->getModel() !== $oldContent->getModel() ) {
+                                                       // The undo may change content
+                                                       // model if its reverting the top
+                                                       // edit. This can result in
+                                                       // mismatched content model/format.
+                                                       $this->contentModel = $newContent->getModel();
+                                                       $this->contentFormat = $oldrev->getContentFormat();
+                                               }
 
-                                                       if ( $newContent->equals( $oldContent ) ) {
-                                                               # Tell the user that the undo results in no change,
-                                                               # i.e. the revisions were already undone.
-                                                               $undoMsg = 'nochange';
-                                                               $content = false;
-                                                       } else {
-                                                               # Inform the user of our success and set an automatic edit summary
-                                                               $undoMsg = 'success';
-
-                                                               # If we just undid one rev, use an autosummary
-                                                               $firstrev = $oldrev->getNext();
-                                                               if ( $firstrev && $firstrev->getId() == $undo ) {
-                                                                       $userText = $undorev->getUserText();
-                                                                       if ( $userText === '' ) {
-                                                                               $undoSummary = $this->context->msg(
-                                                                                       'undo-summary-username-hidden',
-                                                                                       $undo
-                                                                               )->inContentLanguage()->text();
-                                                                       } else {
-                                                                               $undoSummary = $this->context->msg(
-                                                                                       'undo-summary',
-                                                                                       $undo,
-                                                                                       $userText
-                                                                               )->inContentLanguage()->text();
-                                                                       }
-                                                                       if ( $this->summary === '' ) {
-                                                                               $this->summary = $undoSummary;
-                                                                       } else {
-                                                                               $this->summary = $undoSummary . $this->context->msg( 'colon-separator' )
-                                                                                       ->inContentLanguage()->text() . $this->summary;
-                                                                       }
-                                                                       $this->undidRev = $undo;
+                                               if ( $newContent->equals( $oldContent ) ) {
+                                                       # Tell the user that the undo results in no change,
+                                                       # i.e. the revisions were already undone.
+                                                       $undoMsg = 'nochange';
+                                                       $content = false;
+                                               } else {
+                                                       # Inform the user of our success and set an automatic edit summary
+                                                       $undoMsg = 'success';
+
+                                                       # If we just undid one rev, use an autosummary
+                                                       $firstrev = $oldrev->getNext();
+                                                       if ( $firstrev && $firstrev->getId() == $undo ) {
+                                                               $userText = $undorev->getUserText();
+                                                               if ( $userText === '' ) {
+                                                                       $undoSummary = $this->context->msg(
+                                                                               'undo-summary-username-hidden',
+                                                                               $undo
+                                                                       )->inContentLanguage()->text();
+                                                               } else {
+                                                                       $undoSummary = $this->context->msg(
+                                                                               'undo-summary',
+                                                                               $undo,
+                                                                               $userText
+                                                                       )->inContentLanguage()->text();
+                                                               }
+                                                               if ( $this->summary === '' ) {
+                                                                       $this->summary = $undoSummary;
+                                                               } else {
+                                                                       $this->summary = $undoSummary . $this->context->msg( 'colon-separator' )
+                                                                               ->inContentLanguage()->text() . $this->summary;
                                                                }
-                                                               $this->formtype = 'diff';
+                                                               $this->undidRev = $undo;
                                                        }
+                                                       $this->formtype = 'diff';
                                                }
-                                       } else {
-                                               // Failed basic sanity checks.
-                                               // Older revisions may have been removed since the link
-                                               // was created, or we may simply have got bogus input.
-                                               $undoMsg = 'norev';
                                        }
-
-                                       $out = $this->context->getOutput();
-                                       // Messages: undo-success, undo-failure, undo-main-slot-only, undo-norev,
-                                       // undo-nochange.
-                                       $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
-                                       $this->editFormPageTop .= Html::rawElement(
-                                               'div', [ 'class' => $class ],
-                                               $out->parseAsInterface(
-                                                       $this->context->msg( 'undo-' . $undoMsg )->plain()
-                                               )
-                                       );
+                               } else {
+                                       // Failed basic sanity checks.
+                                       // Older revisions may have been removed since the link
+                                       // was created, or we may simply have got bogus input.
+                                       $undoMsg = 'norev';
                                }
 
-                               if ( $content === false ) {
-                                       // Hack for restoring old revisions while EditPage
-                                       // can't handle multi-slot editing.
+                               $out = $this->context->getOutput();
+                               // Messages: undo-success, undo-failure, undo-main-slot-only, undo-norev,
+                               // undo-nochange.
+                               $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
+                               $this->editFormPageTop .= Html::rawElement(
+                                       'div', [ 'class' => $class ],
+                                       $out->parseAsInterface(
+                                               $this->context->msg( 'undo-' . $undoMsg )->plain()
+                                       )
+                               );
+                       }
 
-                                       $curRevision = $this->page->getRevision();
-                                       $oldRevision = $this->mArticle->getRevisionFetched();
+                       if ( $content === false ) {
+                               // Hack for restoring old revisions while EditPage
+                               // can't handle multi-slot editing.
 
-                                       if ( $curRevision
-                                               && $oldRevision
-                                               && $curRevision->getId() !== $oldRevision->getId()
-                                               && ( WikiPage::hasDifferencesOutsideMainSlot( $oldRevision, $curRevision )
-                                                       || !$this->isSupportedContentModel( $oldRevision->getContentModel() ) )
-                                       ) {
-                                               $this->context->getOutput()->redirect(
-                                                       $this->mTitle->getFullURL(
-                                                               [
-                                                                       'action' => 'mcrrestore',
-                                                                       'restore' => $oldRevision->getId(),
-                                                               ]
-                                                       )
-                                               );
+                               $curRevision = $this->page->getRevision();
+                               $oldRevision = $this->mArticle->getRevisionFetched();
 
-                                               return false;
-                                       }
-                               }
+                               if ( $curRevision
+                                       && $oldRevision
+                                       && $curRevision->getId() !== $oldRevision->getId()
+                                       && ( WikiPage::hasDifferencesOutsideMainSlot( $oldRevision, $curRevision )
+                                               || !$this->isSupportedContentModel( $oldRevision->getContentModel() ) )
+                               ) {
+                                       $this->context->getOutput()->redirect(
+                                               $this->mTitle->getFullURL(
+                                                       [
+                                                               'action' => 'mcrrestore',
+                                                               'restore' => $oldRevision->getId(),
+                                                       ]
+                                               )
+                                       );
 
-                               if ( $content === false ) {
-                                       $content = $this->getOriginalContent( $user );
+                                       return false;
                                }
                        }
+
+                       if ( $content === false ) {
+                               $content = $this->getOriginalContent( $user );
+                       }
                }
 
                return $content;
@@ -2804,11 +2802,9 @@ ERROR;
 
                $out->addHTML( $this->editFormTextTop );
 
-               if ( $this->wasDeletedSinceLastEdit() ) {
-                       if ( $this->formtype !== 'save' ) {
-                               $out->wrapWikiMsg( "<div class='error mw-deleted-while-editing'>\n$1\n</div>",
-                                       'deletedwhileediting' );
-                       }
+               if ( $this->wasDeletedSinceLastEdit() && $this->formtype !== 'save' ) {
+                       $out->wrapWikiMsg( "<div class='error mw-deleted-while-editing'>\n$1\n</div>",
+                               'deletedwhileediting' );
                }
 
                // @todo add EditForm plugin interface and use it here!
@@ -3076,12 +3072,12 @@ ERROR;
                        $this->addExplainConflictHeader( $out );
                        $this->editRevId = $this->page->getLatest();
                } else {
-                       if ( $this->section != '' && $this->section != 'new' ) {
-                               if ( !$this->summary && !$this->preview && !$this->diff ) {
-                                       $sectionTitle = self::extractSectionTitle( $this->textbox1 ); // FIXME: use Content object
-                                       if ( $sectionTitle !== false ) {
-                                               $this->summary = "/* $sectionTitle */ ";
-                                       }
+                       if ( $this->section != '' && $this->section != 'new' && !$this->summary &&
+                               !$this->preview && !$this->diff
+                       ) {
+                               $sectionTitle = self::extractSectionTitle( $this->textbox1 ); // FIXME: use Content object
+                               if ( $sectionTitle !== false ) {
+                                       $this->summary = "/* $sectionTitle */ ";
                                }
                        }
 
@@ -3188,44 +3184,42 @@ ERROR;
                                        'anonpreviewwarning'
                                );
                        }
-               } else {
-                       if ( $this->mTitle->isUserConfigPage() ) {
-                               # Check the skin exists
-                               if ( $this->isWrongCaseUserConfigPage() ) {
-                                       $out->wrapWikiMsg(
-                                               "<div class='error' id='mw-userinvalidconfigtitle'>\n$1\n</div>",
-                                               [ 'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ]
-                                       );
-                               }
-                               if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
-                                       $isUserCssConfig = $this->mTitle->isUserCssConfigPage();
-                                       $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
-                                       $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
-
-                                       $warning = $isUserCssConfig
-                                               ? 'usercssispublic'
-                                               : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' );
-
-                                       $out->wrapWikiMsg( '<div class="mw-userconfigpublic">$1</div>', $warning );
-
-                                       if ( $this->formtype !== 'preview' ) {
-                                               $config = $this->context->getConfig();
-                                               if ( $isUserCssConfig && $config->get( 'AllowUserCss' ) ) {
-                                                       $out->wrapWikiMsg(
-                                                               "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
-                                                               [ 'usercssyoucanpreview' ]
-                                                       );
-                                               } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) {
-                                                       $out->wrapWikiMsg(
-                                                               "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
-                                                               [ 'userjsonyoucanpreview' ]
-                                                       );
-                                               } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) {
-                                                       $out->wrapWikiMsg(
-                                                               "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
-                                                               [ 'userjsyoucanpreview' ]
-                                                       );
-                                               }
+               } elseif ( $this->mTitle->isUserConfigPage() ) {
+                       # Check the skin exists
+                       if ( $this->isWrongCaseUserConfigPage() ) {
+                               $out->wrapWikiMsg(
+                                       "<div class='error' id='mw-userinvalidconfigtitle'>\n$1\n</div>",
+                                       [ 'userinvalidconfigtitle', $this->mTitle->getSkinFromConfigSubpage() ]
+                               );
+                       }
+                       if ( $this->getTitle()->isSubpageOf( $user->getUserPage() ) ) {
+                               $isUserCssConfig = $this->mTitle->isUserCssConfigPage();
+                               $isUserJsonConfig = $this->mTitle->isUserJsonConfigPage();
+                               $isUserJsConfig = $this->mTitle->isUserJsConfigPage();
+
+                               $warning = $isUserCssConfig
+                                       ? 'usercssispublic'
+                                       : ( $isUserJsonConfig ? 'userjsonispublic' : 'userjsispublic' );
+
+                               $out->wrapWikiMsg( '<div class="mw-userconfigpublic">$1</div>', $warning );
+
+                               if ( $this->formtype !== 'preview' ) {
+                                       $config = $this->context->getConfig();
+                                       if ( $isUserCssConfig && $config->get( 'AllowUserCss' ) ) {
+                                               $out->wrapWikiMsg(
+                                                       "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
+                                                       [ 'usercssyoucanpreview' ]
+                                               );
+                                       } elseif ( $isUserJsonConfig /* No comparable 'AllowUserJson' */ ) {
+                                               $out->wrapWikiMsg(
+                                                       "<div id='mw-userjsonyoucanpreview'>\n$1\n</div>",
+                                                       [ 'userjsonyoucanpreview' ]
+                                               );
+                                       } elseif ( $isUserJsConfig && $config->get( 'AllowUserJs' ) ) {
+                                               $out->wrapWikiMsg(
+                                                       "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
+                                                       [ 'userjsyoucanpreview' ]
+                                               );
                                        }
                                }
                        }
@@ -3309,10 +3303,8 @@ ERROR;
                        if ( $this->nosummary ) {
                                return;
                        }
-               } else {
-                       if ( !$this->mShowSummaryField ) {
-                               return;
-                       }
+               } elseif ( !$this->mShowSummaryField ) {
+                       return;
                }
 
                $labelText = $this->context->msg( $isSubjectPreview ? 'subject' : 'summary' )->parse();
@@ -4450,16 +4442,14 @@ ERROR;
                                        $lang->formatNum( $maxArticleSize )
                                ]
                        );
-               } else {
-                       if ( !$this->context->msg( 'longpage-hint' )->isDisabled() ) {
-                               $out->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
-                                       [
-                                               'longpage-hint',
-                                               $lang->formatSize( strlen( $this->textbox1 ) ),
-                                               strlen( $this->textbox1 )
-                                       ]
-                               );
-                       }
+               } elseif ( !$this->context->msg( 'longpage-hint' )->isDisabled() ) {
+                       $out->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
+                               [
+                                       'longpage-hint',
+                                       $lang->formatSize( strlen( $this->textbox1 ) ),
+                                       strlen( $this->textbox1 )
+                               ]
+                       );
                }
        }
 
index 9fd1e4f..dddbad5 100644 (file)
@@ -178,15 +178,13 @@ class ForeignResourceManager {
                if ( $integrity === $actualIntegrity ) {
                        $this->verbose( "... passed integrity check for {$src}\n" );
                        $this->cacheSet( $key, $data );
+               } elseif ( $this->action === 'make-sri' ) {
+                       $this->output( "Integrity for {$src}\n\tintegrity: ${actualIntegrity}\n" );
                } else {
-                       if ( $this->action === 'make-sri' ) {
-                               $this->output( "Integrity for {$src}\n\tintegrity: ${actualIntegrity}\n" );
-                       } else {
-                               throw new Exception( "Integrity check failed for {$src}\n" .
-                                       "\tExpected: {$integrity}\n" .
-                                       "\tActual: {$actualIntegrity}"
-                               );
-                       }
+                       throw new Exception( "Integrity check failed for {$src}\n" .
+                               "\tExpected: {$integrity}\n" .
+                               "\tActual: {$actualIntegrity}"
+                       );
                }
                return $data;
        }
index 20f3fd0..b0a79e8 100644 (file)
@@ -1750,13 +1750,11 @@ function wfResetOutputBuffers( $resetGzipEncoding = true ) {
                        // to avoid getting in some kind of infinite loop.
                        break;
                }
-               if ( $resetGzipEncoding ) {
-                       if ( $status['name'] == 'ob_gzhandler' ) {
-                               // Reset the 'Content-Encoding' field set by this handler
-                               // so we can start fresh.
-                               header_remove( 'Content-Encoding' );
-                               break;
-                       }
+               if ( $resetGzipEncoding && $status['name'] == 'ob_gzhandler' ) {
+                       // Reset the 'Content-Encoding' field set by this handler
+                       // so we can start fresh.
+                       header_remove( 'Content-Encoding' );
+                       break;
                }
        }
 }
index 61785d5..aa51243 100644 (file)
@@ -574,10 +574,8 @@ class Html {
                $attrs = [];
                if ( $nonce !== null ) {
                        $attrs['nonce'] = $nonce;
-               } else {
-                       if ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
-                               wfWarn( "no nonce set on script. CSP will break it" );
-                       }
+               } elseif ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
+                       wfWarn( "no nonce set on script. CSP will break it" );
                }
 
                if ( preg_match( '/<\/?script/i', $contents ) ) {
@@ -600,10 +598,8 @@ class Html {
                $attrs = [ 'src' => $url ];
                if ( $nonce !== null ) {
                        $attrs['nonce'] = $nonce;
-               } else {
-                       if ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
-                               wfWarn( "no nonce set on script. CSP will break it" );
-                       }
+               } elseif ( ContentSecurityPolicy::isNonceRequired( RequestContext::getMain()->getConfig() ) ) {
+                       wfWarn( "no nonce set on script. CSP will break it" );
                }
 
                return self::element( 'script', $attrs );
index 3079c65..cbe5a1a 100644 (file)
@@ -86,10 +86,8 @@ class MWGrants {
         * @return string[] Corresponding grant descriptions
         */
        public static function grantNames( array $grants, $lang = null ) {
-               if ( $lang !== null ) {
-                       if ( is_string( $lang ) ) {
-                               $lang = Language::factory( $lang );
-                       }
+               if ( $lang !== null && is_string( $lang ) ) {
+                       $lang = Language::factory( $lang );
                }
 
                $ret = [];
index 8cb9152..24aca2e 100644 (file)
@@ -428,11 +428,9 @@ class MediaWiki {
                        if ( !$ignoreRedirect && ( $target || $page->isRedirect() ) ) {
                                // Is the target already set by an extension?
                                $target = $target ?: $page->followRedirect();
-                               if ( is_string( $target ) ) {
-                                       if ( !$this->config->get( 'DisableHardRedirects' ) ) {
-                                               // we'll need to redirect
-                                               return $target;
-                                       }
+                               if ( is_string( $target ) && !$this->config->get( 'DisableHardRedirects' ) ) {
+                                       // we'll need to redirect
+                                       return $target;
                                }
                                if ( is_object( $target ) ) {
                                        // Rewrite environment to redirected article
index 4049e11..0b3113f 100644 (file)
@@ -1163,14 +1163,11 @@ class Message implements MessageSpecifier, Serializable {
                                        // escaped, breaking the replacement and avoiding XSS.
                                        $replacementKeys['$' . ( $n + 1 )] = $marker . ( $n + 1 );
                                }
-                       } else {
-                               if ( $paramType === 'after' ) {
-                                       $replacementKeys[$marker . ( $n + 1 )] = $value;
-                               }
+                       } elseif ( $paramType === 'after' ) {
+                               $replacementKeys[$marker . ( $n + 1 )] = $value;
                        }
                }
-               $message = strtr( $message, $replacementKeys );
-               return $message;
+               return strtr( $message, $replacementKeys );
        }
 
        /**
index 8a19c51..786ecc4 100644 (file)
@@ -3785,26 +3785,24 @@ class OutputPage extends ContextSource {
                if ( $config->get( 'EnableCanonicalServerLink' ) ) {
                        if ( $canonicalUrl !== false ) {
                                $canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL );
-                       } else {
-                               if ( $this->isArticleRelated() ) {
-                                       // This affects all requests where "setArticleRelated" is true. This is
-                                       // typically all requests that show content (query title, curid, oldid, diff),
-                                       // and all wikipage actions (edit, delete, purge, info, history etc.).
-                                       // It does not apply to File pages and Special pages.
-                                       // 'history' and 'info' actions address page metadata rather than the page
-                                       // content itself, so they may not be canonicalized to the view page url.
-                                       // TODO: this ought to be better encapsulated in the Action class.
-                                       $action = Action::getActionName( $this->getContext() );
-                                       if ( in_array( $action, [ 'history', 'info' ] ) ) {
-                                               $query = "action={$action}";
-                                       } else {
-                                               $query = '';
-                                       }
-                                       $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+                       } elseif ( $this->isArticleRelated() ) {
+                               // This affects all requests where "setArticleRelated" is true. This is
+                               // typically all requests that show content (query title, curid, oldid, diff),
+                               // and all wikipage actions (edit, delete, purge, info, history etc.).
+                               // It does not apply to File pages and Special pages.
+                               // 'history' and 'info' actions address page metadata rather than the page
+                               // content itself, so they may not be canonicalized to the view page url.
+                               // TODO: this ought to be better encapsulated in the Action class.
+                               $action = Action::getActionName( $this->getContext() );
+                               if ( in_array( $action, [ 'history', 'info' ] ) ) {
+                                       $query = "action={$action}";
                                } else {
-                                       $reqUrl = $this->getRequest()->getRequestURL();
-                                       $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
+                                       $query = '';
                                }
+                               $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+                       } else {
+                               $reqUrl = $this->getRequest()->getRequestURL();
+                               $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
                        }
                }
                if ( $canonicalUrl !== false ) {
@@ -3948,10 +3946,8 @@ class OutputPage extends ContextSource {
         * @return string HTML fragment
         */
        protected function styleLink( $style, array $options ) {
-               if ( isset( $options['dir'] ) ) {
-                       if ( $this->getLanguage()->getDir() != $options['dir'] ) {
-                               return '';
-                       }
+               if ( isset( $options['dir'] ) && $this->getLanguage()->getDir() != $options['dir'] ) {
+                       return '';
                }
 
                if ( isset( $options['media'] ) ) {
index df2451c..a84370f 100644 (file)
@@ -129,12 +129,10 @@ class PageProps {
                                if ( $propertyValue === false ) {
                                        $queryIDs[] = $pageID;
                                        break;
+                               } elseif ( $gotArray ) {
+                                       $values[$pageID][$propertyName] = $propertyValue;
                                } else {
-                                       if ( $gotArray ) {
-                                               $values[$pageID][$propertyName] = $propertyValue;
-                                       } else {
-                                               $values[$pageID] = $propertyValue;
-                                       }
+                                       $values[$pageID] = $propertyValue;
                                }
                        }
                }
index db12e74..eb52d7c 100644 (file)
@@ -133,10 +133,8 @@ class PathRouter {
                // Loop over our options and convert any single value $# restrictions
                // into an array so we only have to do in_array tests.
                foreach ( $options as $optionName => $optionData ) {
-                       if ( preg_match( '/^\$\d+$/u', $optionName ) ) {
-                               if ( !is_array( $optionData ) ) {
-                                       $options[$optionName] = [ $optionData ];
-                               }
+                       if ( preg_match( '/^\$\d+$/u', $optionName ) && !is_array( $optionData ) ) {
+                               $options[$optionName] = [ $optionData ];
                        }
                }
 
index f3e5a85..0139103 100644 (file)
@@ -86,10 +86,8 @@ class MainSlotRoleHandler extends SlotRoleHandler {
 
                // Hook can determine default model
                $title = Title::newFromLinkTarget( $page );
-               if ( !Hooks::run( 'ContentHandlerDefaultModelFor', [ $title, &$model ] ) ) {
-                       if ( !is_null( $model ) ) {
-                               return $model;
-                       }
+               if ( !Hooks::run( 'ContentHandlerDefaultModelFor', [ $title, &$model ] ) && !is_null( $model ) ) {
+                       return $model;
                }
 
                // Could this page contain code based on the title?
index 9af2458..2a54a9b 100644 (file)
@@ -1863,12 +1863,12 @@ class RevisionStore
                }
 
                // if we have a content object, use it to set the model and type
-               if ( !empty( $fields['content'] ) ) {
-                       if ( !( $fields['content'] instanceof Content ) && !is_array( $fields['content'] ) ) {
-                               throw new MWException(
-                                       'content field must contain a Content object or an array of Content objects.'
-                               );
-                       }
+               if ( !empty( $fields['content'] ) && !( $fields['content'] instanceof Content )
+                       && !is_array( $fields['content'] )
+               ) {
+                       throw new MWException(
+                               'content field must contain a Content object or an array of Content objects.'
+                       );
                }
 
                if ( !empty( $fields['text_id'] ) ) {
index 0c62c4f..6d86b22 100644 (file)
@@ -3556,10 +3556,8 @@ class Title implements LinkTarget, IDBAccessObject {
                        $linkCache->clearLink( $this );
                        $this->mArticleID = $linkCache->addLinkObj( $this );
                        $linkCache->forUpdate( $oldUpdate );
-               } else {
-                       if ( $this->mArticleID == -1 ) {
-                               $this->mArticleID = $linkCache->addLinkObj( $this );
-                       }
+               } elseif ( $this->mArticleID == -1 ) {
+                       $this->mArticleID = $linkCache->addLinkObj( $this );
                }
                return $this->mArticleID;
        }
index d1a56bf..febf03e 100644 (file)
@@ -47,12 +47,10 @@ class Xml {
                }
                if ( is_null( $contents ) ) {
                        $out .= '>';
+               } elseif ( $allowShortTag && $contents === '' ) {
+                       $out .= ' />';
                } else {
-                       if ( $allowShortTag && $contents === '' ) {
-                               $out .= ' />';
-                       } else {
-                               $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
-                       }
+                       $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
                }
                return $out;
        }
index ed58686..4cb7dda 100644 (file)
@@ -222,12 +222,10 @@ class CreditsAction extends FormlessAction {
                $link = $this->link( $user );
                if ( $user->isAnon() ) {
                        return $this->msg( 'anonuser' )->rawParams( $link )->parse();
+               } elseif ( $this->canShowRealUserName() && $user->getRealName() ) {
+                       return $link;
                } else {
-                       if ( $this->canShowRealUserName() && $user->getRealName() ) {
-                               return $link;
-                       } else {
-                               return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
-                       }
+                       return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
                }
        }
 
index 4ba30ab..1eb5e8d 100644 (file)
@@ -307,10 +307,8 @@ class ApiComparePages extends ApiBase {
                foreach ( [ 'from', 'to' ] as $prefix ) {
                        if ( $params["{$prefix}rev"] !== null ) {
                                $rev = $this->getRevisionById( $params["{$prefix}rev"] );
-                               if ( $rev ) {
-                                       if ( $rev->hasSlot( $role ) ) {
-                                               return $rev->getSlot( $role, RevisionRecord::RAW )->getModel();
-                                       }
+                               if ( $rev && $rev->hasSlot( $role ) ) {
+                                       return $rev->getSlot( $role, RevisionRecord::RAW )->getModel();
                                }
                        }
                }
index 886dbcc..1656e7c 100644 (file)
@@ -559,11 +559,9 @@ class ApiHelp extends ApiBase {
                                                                                $arr = &$submodules;
                                                                                try {
                                                                                        $submod = $module->getModuleFromPath( $m );
-                                                                                       if ( $submod ) {
-                                                                                               if ( $submod->isDeprecated() ) {
-                                                                                                       $arr = &$deprecatedSubmodules;
-                                                                                                       $attrs['class'] = 'apihelp-deprecated-value';
-                                                                                               }
+                                                                                       if ( $submod && $submod->isDeprecated() ) {
+                                                                                               $arr = &$deprecatedSubmodules;
+                                                                                               $attrs['class'] = 'apihelp-deprecated-value';
                                                                                        }
                                                                                } catch ( ApiUsageException $ex ) {
                                                                                        // Ignore
index f60443c..588e31a 100644 (file)
@@ -1117,19 +1117,17 @@ class ApiMain extends ApiBase {
                                        . $this->msg( 'api-usage-mailinglist-ref' )->inLanguage( $formatter->getLanguage() )->text()
                                )
                        );
-               } else {
-                       if ( $config->get( 'ShowExceptionDetails' ) ) {
-                               $result->addContentValue(
-                                       $path,
-                                       'trace',
-                                       $this->msg( 'api-exception-trace',
-                                               get_class( $e ),
-                                               $e->getFile(),
-                                               $e->getLine(),
-                                               MWExceptionHandler::getRedactedTraceAsString( $e )
-                                       )->inLanguage( $formatter->getLanguage() )->text()
-                               );
-                       }
+               } elseif ( $config->get( 'ShowExceptionDetails' ) ) {
+                       $result->addContentValue(
+                               $path,
+                               'trace',
+                               $this->msg( 'api-exception-trace',
+                                       get_class( $e ),
+                                       $e->getFile(),
+                                       $e->getLine(),
+                                       MWExceptionHandler::getRedactedTraceAsString( $e )
+                               )->inLanguage( $formatter->getLanguage() )->text()
+                       );
                }
 
                // Add the id and such
index 450ebb6..b321c7d 100644 (file)
@@ -1398,10 +1398,10 @@ class ApiPageSet extends ApiBase {
                                                $data[$toPageId],
                                                $this->mGeneratorData[$fromNs][$fromDBkey]
                                        );
-                                       if ( $result instanceof ApiResult ) {
-                                               if ( !$result->addValue( $path, $toPageId, $data[$toPageId], ApiResult::OVERRIDE ) ) {
-                                                       return false;
-                                               }
+                                       if ( $result instanceof ApiResult &&
+                                               !$result->addValue( $path, $toPageId, $data[$toPageId], ApiResult::OVERRIDE )
+                                       ) {
+                                               return false;
                                        }
                                }
                        }
index 3070665..d955b56 100644 (file)
@@ -157,16 +157,14 @@ abstract class ApiQueryBase extends ApiBase {
         */
        protected function addTables( $tables, $alias = null ) {
                if ( is_array( $tables ) ) {
-                       if ( !is_null( $alias ) ) {
+                       if ( $alias !== null ) {
                                ApiBase::dieDebug( __METHOD__, 'Multiple table aliases not supported' );
                        }
                        $this->tables = array_merge( $this->tables, $tables );
+               } elseif ( $alias !== null ) {
+                       $this->tables[$alias] = $tables;
                } else {
-                       if ( !is_null( $alias ) ) {
-                               $this->tables[$alias] = $tables;
-                       } else {
-                               $this->tables[] = $tables;
-                       }
+                       $this->tables[] = $tables;
                }
        }
 
index 333b769..051e127 100644 (file)
@@ -249,13 +249,11 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        // Don't set $scale['width']; this signals mergeThumbParams() to fill it with the image's width
                        $scale = [];
                        $scale['height'] = $params['urlheight'];
+               } elseif ( $params['urlparam'] ) {
+                       // Audio files might not have a width/height.
+                       $scale = [];
                } else {
-                       if ( $params['urlparam'] ) {
-                               // Audio files might not have a width/height.
-                               $scale = [];
-                       } else {
-                               $scale = null;
-                       }
+                       $scale = null;
                }
 
                return $scale;
index 3d358b9..a5437ba 100644 (file)
@@ -515,10 +515,8 @@ class ApiQueryInfo extends ApiQueryBase {
                        }
                }
 
-               if ( $this->fld_varianttitles ) {
-                       if ( isset( $this->variantTitles[$pageid] ) ) {
-                               $pageInfo['varianttitles'] = $this->variantTitles[$pageid];
-                       }
+               if ( $this->fld_varianttitles && isset( $this->variantTitles[$pageid] ) ) {
+                       $pageInfo['varianttitles'] = $this->variantTitles[$pageid];
                }
 
                if ( $this->params['testactions'] ) {
index f594347..d2a7eec 100644 (file)
@@ -202,13 +202,11 @@ class ApiQueryUserInfo extends ApiQueryBase {
                        $vals['realname'] = $user->getRealName();
                }
 
-               if ( $user->isAllowed( 'viewmyprivateinfo' ) ) {
-                       if ( isset( $this->prop['email'] ) ) {
-                               $vals['email'] = $user->getEmail();
-                               $auth = $user->getEmailAuthenticationTimestamp();
-                               if ( !is_null( $auth ) ) {
-                                       $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth );
-                               }
+               if ( $user->isAllowed( 'viewmyprivateinfo' ) && isset( $this->prop['email'] ) ) {
+                       $vals['email'] = $user->getEmail();
+                       $auth = $user->getEmailAuthenticationTimestamp();
+                       if ( $auth !== null ) {
+                               $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth );
                        }
                }
 
index cb49622..578a908 100644 (file)
@@ -81,10 +81,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->fld_loginfo = isset( $prop['loginfo'] );
                        $this->fld_tags = isset( $prop['tags'] );
 
-                       if ( $this->fld_patrol ) {
-                               if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
-                                       $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'patrol' );
-                               }
+                       if ( $this->fld_patrol && !$user->useRCPatrol() && !$user->useNPPatrol() ) {
+                               $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'patrol' );
                        }
 
                        if ( $this->fld_comment || $this->fld_parsedcomment ) {
@@ -192,12 +190,10 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        $startFrom = [ $recentChangeInfo['rc_timestamp'], $recentChangeInfo['rc_id'] ];
                                        break;
                                }
+                       } elseif ( $params['allrev'] ) {
+                               $ids[] = (int)$recentChangeInfo['rc_this_oldid'];
                        } else {
-                               if ( $params['allrev'] ) {
-                                       $ids[] = (int)$recentChangeInfo['rc_this_oldid'];
-                               } else {
-                                       $ids[] = (int)$recentChangeInfo['rc_cur_id'];
-                               }
+                               $ids[] = (int)$recentChangeInfo['rc_cur_id'];
                        }
                }
 
index bfe278b..3515a70 100644 (file)
@@ -2101,10 +2101,8 @@ class AuthManager implements LoggerAwareInterface {
                                $id = $req->getUniqueId();
 
                                // If a required request if from a Primary, mark it as "primary-required" instead
-                               if ( $isPrimary ) {
-                                       if ( $req->required ) {
-                                               $req->required = AuthenticationRequest::PRIMARY_REQUIRED;
-                                       }
+                               if ( $isPrimary && $req->required ) {
+                                       $req->required = AuthenticationRequest::PRIMARY_REQUIRED;
                                }
 
                                if (
index 047a811..b646380 100644 (file)
@@ -303,18 +303,16 @@ class LocalPasswordPrimaryAuthenticationProvider
                }
 
                $req = AuthenticationRequest::getRequestByClass( $reqs, PasswordAuthenticationRequest::class );
-               if ( $req ) {
-                       if ( $req->username !== null && $req->password !== null ) {
-                               // Nothing we can do besides claim it, because the user isn't in
-                               // the DB yet
-                               if ( $req->username !== $user->getName() ) {
-                                       $req = clone $req;
-                                       $req->username = $user->getName();
-                               }
-                               $ret = AuthenticationResponse::newPass( $req->username );
-                               $ret->createRequest = $req;
-                               return $ret;
+               if ( $req && $req->username !== null && $req->password !== null ) {
+                       // Nothing we can do besides claim it, because the user isn't in
+                       // the DB yet
+                       if ( $req->username !== $user->getName() ) {
+                               $req = clone $req;
+                               $req->username = $user->getName();
                        }
+                       $ret = AuthenticationResponse::newPass( $req->username );
+                       $ret->createRequest = $req;
+                       return $ret;
                }
                return AuthenticationResponse::newAbstain();
        }
index 045f791..e129538 100644 (file)
@@ -356,23 +356,21 @@ class TemporaryPasswordPrimaryAuthenticationProvider
                $req = AuthenticationRequest::getRequestByClass(
                        $reqs, TemporaryPasswordAuthenticationRequest::class
                );
-               if ( $req ) {
-                       if ( $req->username !== null && $req->password !== null ) {
-                               // Nothing we can do yet, because the user isn't in the DB yet
-                               if ( $req->username !== $user->getName() ) {
-                                       $req = clone $req;
-                                       $req->username = $user->getName();
-                               }
-
-                               if ( $req->mailpassword ) {
-                                       // prevent EmailNotificationSecondaryAuthenticationProvider from sending another mail
-                                       $this->manager->setAuthenticationSessionData( 'no-email', true );
-                               }
+               if ( $req && $req->username !== null && $req->password !== null ) {
+                       // Nothing we can do yet, because the user isn't in the DB yet
+                       if ( $req->username !== $user->getName() ) {
+                               $req = clone $req;
+                               $req->username = $user->getName();
+                       }
 
-                               $ret = AuthenticationResponse::newPass( $req->username );
-                               $ret->createRequest = $req;
-                               return $ret;
+                       if ( $req->mailpassword ) {
+                               // prevent EmailNotificationSecondaryAuthenticationProvider from sending another mail
+                               $this->manager->setAuthenticationSessionData( 'no-email', true );
                        }
+
+                       $ret = AuthenticationResponse::newPass( $req->username );
+                       $ret->createRequest = $req;
+                       return $ret;
                }
                return AuthenticationResponse::newAbstain();
        }
index d7669eb..ec6ce04 100644 (file)
@@ -221,13 +221,11 @@ class CacheHelper implements ICacheHelper {
                                } else {
                                        $value = array_shift( $this->cachedChunks );
                                }
+                       } elseif ( array_key_exists( $key, $this->cachedChunks ) ) {
+                               $value = $this->cachedChunks[$key];
+                               unset( $this->cachedChunks[$key] );
                        } else {
-                               if ( array_key_exists( $key, $this->cachedChunks ) ) {
-                                       $value = $this->cachedChunks[$key];
-                                       unset( $this->cachedChunks[$key] );
-                               } else {
-                                       wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ );
-                               }
+                               wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ );
                        }
                } else {
                        if ( !is_array( $args ) ) {
index 3a89066..a0d61b2 100644 (file)
@@ -128,10 +128,8 @@ class HTMLFileCache extends FileCacheBase {
                        return false;
                }
 
-               if ( $mode === self::MODE_NORMAL ) {
-                       if ( $user->getNewtalk() ) {
-                               return false;
-                       }
+               if ( ( $mode === self::MODE_NORMAL ) && $user->getNewtalk() ) {
+                       return false;
                }
 
                // Allow extensions to disable caching
@@ -211,18 +209,14 @@ class HTMLFileCache extends FileCacheBase {
                }
 
                // gzip output to buffer as needed and set headers...
-               if ( $this->useGzip() ) {
-                       // @todo Ugly wfClientAcceptsGzip() function - use context!
-                       if ( wfClientAcceptsGzip() ) {
-                               header( 'Content-Encoding: gzip' );
+               // @todo Ugly wfClientAcceptsGzip() function - use context!
+               if ( $this->useGzip() && wfClientAcceptsGzip() ) {
+                       header( 'Content-Encoding: gzip' );
 
-                               return $compressed;
-                       } else {
-                               return $text;
-                       }
-               } else {
-                       return $text;
+                       return $compressed;
                }
+
+               return $text;
        }
 
        /**
index 8d199e2..a8f542f 100644 (file)
@@ -75,22 +75,22 @@ class FileDependency extends CacheDependency {
                        if ( $this->timestamp === false ) {
                                # Still nonexistent
                                return false;
-                       } else {
-                               # Deleted
-                               wfDebug( "Dependency triggered: {$this->filename} deleted.\n" );
-
-                               return true;
                        }
-               } else {
-                       if ( $lastmod > $this->timestamp ) {
-                               # Modified or created
-                               wfDebug( "Dependency triggered: {$this->filename} changed.\n" );
 
-                               return true;
-                       } else {
-                               # Not modified
-                               return false;
-                       }
+                       # Deleted
+                       wfDebug( "Dependency triggered: {$this->filename} deleted.\n" );
+
+                       return true;
                }
+
+               if ( $lastmod > $this->timestamp ) {
+                       # Modified or created
+                       wfDebug( "Dependency triggered: {$this->filename} changed.\n" );
+
+                       return true;
+               }
+
+               # Not modified
+               return false;
        }
 }
index 246a3dd..8814cff 100644 (file)
@@ -86,11 +86,9 @@ class LCStoreCDB implements LCStore {
        }
 
        public function startWrite( $code ) {
-               if ( !file_exists( $this->directory ) ) {
-                       if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
-                               throw new MWException( "Unable to create the localisation store " .
-                                       "directory \"{$this->directory}\"" );
-                       }
+               if ( !file_exists( $this->directory ) && !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
+                       throw new MWException( "Unable to create the localisation store " .
+                               "directory \"{$this->directory}\"" );
                }
 
                // Close reader to stop permission errors on write
index f860146..d3504a8 100644 (file)
@@ -45,11 +45,9 @@ class LCStoreStaticArray implements LCStore {
        }
 
        public function startWrite( $code ) {
-               if ( !file_exists( $this->directory ) ) {
-                       if ( !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
-                               throw new MWException( "Unable to create the localisation store " .
-                                       "directory \"{$this->directory}\"" );
-                       }
+               if ( !file_exists( $this->directory ) && !wfMkdirParents( $this->directory, null, __METHOD__ ) ) {
+                       throw new MWException( "Unable to create the localisation store " .
+                               "directory \"{$this->directory}\"" );
                }
 
                $this->currentLang = $code;
index d45b2ce..9c1c5f8 100644 (file)
@@ -365,16 +365,14 @@ class IcuCollation extends Collation {
                        foreach ( $digits as $digit ) {
                                $letters[] = $this->digitTransformLanguage->formatNum( $digit, true );
                        }
+               } elseif ( $this->locale === 'root' ) {
+                       $letters = require "$IP/includes/collation/data/first-letters-root.php";
                } else {
-                       if ( $this->locale === 'root' ) {
-                               $letters = require "$IP/includes/collation/data/first-letters-root.php";
-                       } else {
-                               // FIXME: Is this still used?
-                               $letters = wfGetPrecompiledData( "first-letters-{$this->locale}.ser" );
-                               if ( $letters === false ) {
-                                       throw new MWException( "MediaWiki does not support ICU locale " .
-                                               "\"{$this->locale}\"" );
-                               }
+                       // FIXME: Is this still used?
+                       $letters = wfGetPrecompiledData( "first-letters-{$this->locale}.ser" );
+                       if ( $letters === false ) {
+                               throw new MWException( "MediaWiki does not support ICU locale " .
+                                       "\"{$this->locale}\"" );
                        }
                }
 
index ca590d8..66775bf 100644 (file)
@@ -71,14 +71,12 @@ class MWExceptionRenderer {
                                                self::getShowBacktraceError( $e );
                                }
                                $message .= "\n";
+                       } elseif ( $wgShowExceptionDetails ) {
+                               $message = MWExceptionHandler::getLogMessage( $e ) .
+                                       "\nBacktrace:\n" .
+                                       MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n";
                        } else {
-                               if ( $wgShowExceptionDetails ) {
-                                       $message = MWExceptionHandler::getLogMessage( $e ) .
-                                               "\nBacktrace:\n" .
-                                               MWExceptionHandler::getRedactedTraceAsString( $e ) . "\n";
-                               } else {
-                                       $message = MWExceptionHandler::getPublicLogMessage( $e );
-                               }
+                               $message = MWExceptionHandler::getPublicLogMessage( $e );
                        }
                        echo nl2br( htmlspecialchars( $message ) ) . "\n";
                }
index 9e4b6df..346ec8e 100644 (file)
@@ -348,14 +348,11 @@ class ForeignAPIRepo extends FileRepo {
                if ( !$knownThumbUrls ) {
                        /* No knownThumbUrls for this file */
                        $knownThumbUrls = [];
-               } else {
-                       if ( isset( $knownThumbUrls[$sizekey] ) ) {
-                               wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
-                                       "{$knownThumbUrls[$sizekey]} \n" );
+               } elseif ( isset( $knownThumbUrls[$sizekey] ) ) {
+                       wfDebug( __METHOD__ . ': Got thumburl from local cache: ' .
+                               "{$knownThumbUrls[$sizekey]} \n" );
 
-                               return $knownThumbUrls[$sizekey];
-                       }
-                       /* This size is not yet known */
+                       return $knownThumbUrls[$sizekey];
                }
 
                $metadata = null;
index c3b5199..97abe33 100644 (file)
@@ -633,20 +633,15 @@ abstract class File implements IDBAccessObject {
                        // one would not expect it to be animated
                        // so true.
                        return true;
-               } else {
-                       if ( $this->allowInlineDisplay()
-                               && $handler->isAnimatedImage( $this )
-                               && !$handler->canAnimateThumbnail( $this )
-                       ) {
-                               // Image is animated, but thumbnail isn't.
-                               // This is unexpected to the user.
-                               return false;
-                       } else {
-                               // Image is not animated, so one would
-                               // not expect thumb to be
-                               return true;
-                       }
                }
+
+               return !$this->allowInlineDisplay()
+                       // Image is not animated, so one would
+                       // not expect thumb to be
+                       || !$handler->isAnimatedImage( $this )
+                       // Image is animated, but thumbnail isn't.
+                       // This is unexpected to the user.
+                       || $handler->canAnimateThumbnail( $this );
        }
 
        /**
index 23ff304..3cdbfc2 100644 (file)
@@ -418,10 +418,10 @@ class OldLocalFile extends LocalFile {
                $dstRel = $this->getArchiveRel( $archiveName );
                $status = $this->publishTo( $srcPath, $dstRel );
 
-               if ( $status->isGood() ) {
-                       if ( !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) ) {
-                               $status->fatal( 'filenotfound', $srcPath );
-                       }
+               if ( $status->isGood() &&
+                       !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user )
+               ) {
+                       $status->fatal( 'filenotfound', $srcPath );
                }
 
                $this->unlock();
index bd492d1..5eab605 100644 (file)
@@ -38,10 +38,8 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace {
                // $value is a string, because HTMLForm fields store their values as strings
                $namespaces = explode( "\n", $value );
 
-               if ( isset( $this->mParams['max'] ) ) {
-                       if ( count( $namespaces ) > $this->mParams['max'] ) {
-                               return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
-                       }
+               if ( isset( $this->mParams['max'] ) && ( count( $namespaces ) > $this->mParams['max'] ) ) {
+                       return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
                }
 
                foreach ( $namespaces as $namespace ) {
index 1cfbd5f..bd1d2d3 100644 (file)
@@ -53,10 +53,8 @@ class HTMLTitlesMultiselectField extends HTMLTitleTextField {
                // $value is a string, because HTMLForm fields store their values as strings
                $titlesArray = explode( "\n", $value );
 
-               if ( isset( $this->mParams['max'] ) ) {
-                       if ( count( $titlesArray ) > $this->mParams['max'] ) {
-                               return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
-                       }
+               if ( isset( $this->mParams['max'] ) && ( count( $titlesArray ) > $this->mParams['max'] ) ) {
+                       return $this->msg( 'htmlform-int-toohigh', $this->mParams['max'] );
                }
 
                foreach ( $titlesArray as $title ) {
index bd19aa7..41ec673 100644 (file)
@@ -286,18 +286,16 @@ class WikiImporter {
 
                        if ( !$title || $title->isExternal() ) {
                                $status->fatal( 'import-rootpage-invalid' );
+                       } elseif ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+                               $displayNSText = $title->getNamespace() == NS_MAIN
+                                       ? wfMessage( 'blanknamespace' )->text()
+                                       : MediaWikiServices::getInstance()->getContentLanguage()->
+                                               getNsText( $title->getNamespace() );
+                               $status->fatal( 'import-rootpage-nosubpage', $displayNSText );
                        } else {
-                               if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
-                                       $displayNSText = $title->getNamespace() == NS_MAIN
-                                               ? wfMessage( 'blanknamespace' )->text()
-                                               : MediaWikiServices::getInstance()->getContentLanguage()->
-                                                       getNsText( $title->getNamespace() );
-                                       $status->fatal( 'import-rootpage-nosubpage', $displayNSText );
-                               } else {
-                                       // set namespace to 'all', so the namespace check in processTitle() can pass
-                                       $this->setTargetNamespace( null );
-                                       $this->setImportTitleFactory( new SubpageImportTitleFactory( $title ) );
-                               }
+                               // set namespace to 'all', so the namespace check in processTitle() can pass
+                               $this->setTargetNamespace( null );
+                               $this->setImportTitleFactory( new SubpageImportTitleFactory( $title ) );
                        }
                }
                return $status;
index f3cbbc4..f9ee319 100644 (file)
@@ -443,11 +443,11 @@ class PostgresInstaller extends DatabaseInstaller {
                        }
                        // Recursively search each member of the group to see if the target
                        // is a member of it, up to the given maximum depth.
-                       if ( $maxDepth > 0 ) {
-                               if ( $this->isRoleMember( $conn, $targetMember, $row->member, $maxDepth - 1 ) ) {
-                                       // Found member of member
-                                       return true;
-                               }
+                       if ( $maxDepth > 0 &&
+                               $this->isRoleMember( $conn, $targetMember, $row->member, $maxDepth - 1 )
+                       ) {
+                               // Found member of member
+                               return true;
                        }
                }
 
index 75877a1..9ba8d02 100644 (file)
@@ -1007,13 +1007,11 @@ END;
        public function addPgExtIndex( $table, $index, $type ) {
                if ( $this->db->indexExists( $table, $index ) ) {
                        $this->output( "...index '$index' on table '$table' already exists\n" );
+               } elseif ( preg_match( '/^\(/', $type ) ) {
+                       $this->output( "Creating index '$index' on table '$table'\n" );
+                       $this->db->query( "CREATE INDEX $index ON $table $type" );
                } else {
-                       if ( preg_match( '/^\(/', $type ) ) {
-                               $this->output( "Creating index '$index' on table '$table'\n" );
-                               $this->db->query( "CREATE INDEX $index ON $table $type" );
-                       } else {
-                               $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
-                       }
+                       $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
                }
        }
 
index 9de1fea..cdb11b0 100644 (file)
@@ -332,10 +332,8 @@ EOT;
                        if ( !is_writable( $file ) ) {
                                return Status::newFatal( 'config-sqlite-readonly', $file );
                        }
-               } else {
-                       if ( file_put_contents( $file, '' ) === false ) {
-                               return Status::newFatal( 'config-sqlite-cant-create-db', $file );
-                       }
+               } elseif ( file_put_contents( $file, '' ) === false ) {
+                       return Status::newFatal( 'config-sqlite-cant-create-db', $file );
                }
 
                return Status::newGood();
index e1070c6..2d12e62 100644 (file)
@@ -1072,12 +1072,10 @@ class WebInstaller extends Installer {
                        if ( $value === null ) {
                                // Checkbox?
                                $this->setVar( $name, false );
+                       } elseif ( stripos( $name, 'password' ) !== false ) {
+                               $this->setPassword( $name, $value );
                        } else {
-                               if ( stripos( $name, 'password' ) !== false ) {
-                                       $this->setPassword( $name, $value );
-                               } else {
-                                       $this->setVar( $name, $value );
-                               }
+                               $this->setVar( $name, $value );
                        }
                }
 
index 8314fd2..1222ac2 100644 (file)
@@ -28,10 +28,8 @@ class WebInstallerName extends WebInstallerPage {
         */
        public function execute() {
                $r = $this->parent->request;
-               if ( $r->wasPosted() ) {
-                       if ( $this->submit() ) {
-                               return 'continue';
-                       }
+               if ( $r->wasPosted() && $this->submit() ) {
+                       return 'continue';
                }
 
                $this->startForm();
index 4794712..bc25179 100644 (file)
@@ -31,10 +31,8 @@ class WebInstallerOptions extends WebInstallerPage {
                        $this->submitSkins();
                        return 'skip';
                }
-               if ( $this->parent->request->wasPosted() ) {
-                       if ( $this->submit() ) {
-                               return 'continue';
-                       }
+               if ( $this->parent->request->wasPosted() && $this->submit() ) {
+                       return 'continue';
                }
 
                $emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
index a4f031c..28e8784 100644 (file)
@@ -25,10 +25,8 @@ class WebInstallerWelcome extends WebInstallerPage {
         * @return string
         */
        public function execute() {
-               if ( $this->parent->request->wasPosted() ) {
-                       if ( $this->getVar( '_Environment' ) ) {
-                               return 'continue';
-                       }
+               if ( $this->parent->request->wasPosted() && $this->getVar( '_Environment' ) ) {
+                       return 'continue';
                }
                $this->parent->output->addWikiTextAsInterface( wfMessage( 'config-welcome' )->plain() );
                $status = $this->parent->doEnvironmentChecks();
index 536177e..a6135ae 100644 (file)
@@ -237,11 +237,9 @@ class MultiHttpClient implements LoggerAwareInterface {
                                        }
                                } while ( $mrc == CURLM_CALL_MULTI_PERFORM );
                                // Wait (if possible) for available work...
-                               if ( $active > 0 && $mrc == CURLM_OK ) {
-                                       if ( curl_multi_select( $chm, $selectTimeout ) == -1 ) {
-                                               // PHP bug 63411; https://curl.haxx.se/libcurl/c/curl_multi_fdset.html
-                                               usleep( 5000 ); // 5ms
-                                       }
+                               if ( $active > 0 && $mrc == CURLM_OK && curl_multi_select( $chm, $selectTimeout ) == -1 ) {
+                                       // PHP bug 63411; https://curl.haxx.se/libcurl/c/curl_multi_fdset.html
+                                       usleep( 5000 ); // 5ms
                                }
                        } while ( $active > 0 && $mrc == CURLM_OK );
                }
index 9524155..f92d5fa 100644 (file)
@@ -257,11 +257,11 @@ class FileBackendMultiWrite extends FileBackend {
                                                $status->fatal( 'backend-fail-synced', $path );
                                                continue;
                                        }
-                                       if ( $this->syncChecks & self::CHECK_SIZE ) {
-                                               if ( $cStat['size'] != $mStat['size'] ) { // wrong size
-                                                       $status->fatal( 'backend-fail-synced', $path );
-                                                       continue;
-                                               }
+                                       if ( ( $this->syncChecks & self::CHECK_SIZE )
+                                               && $cStat['size'] != $mStat['size']
+                                       ) { // wrong size
+                                               $status->fatal( 'backend-fail-synced', $path );
+                                               continue;
                                        }
                                        if ( $this->syncChecks & self::CHECK_TIME ) {
                                                $mTs = wfTimestamp( TS_UNIX, $mStat['mtime'] );
@@ -271,16 +271,12 @@ class FileBackendMultiWrite extends FileBackend {
                                                        continue;
                                                }
                                        }
-                                       if ( $this->syncChecks & self::CHECK_SHA1 ) {
-                                               if ( $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
-                                                       $status->fatal( 'backend-fail-synced', $path );
-                                                       continue;
-                                               }
-                                       }
-                               } else { // file is not in master
-                                       if ( $cStat ) { // file should not exist
+                                       if ( ( $this->syncChecks & self::CHECK_SHA1 ) && $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
                                                $status->fatal( 'backend-fail-synced', $path );
+                                               continue;
                                        }
+                               } elseif ( $cStat ) { // file is not in master; file should not exist
+                                       $status->fatal( 'backend-fail-synced', $path );
                                }
                        }
                }
index 993eea9..746f3f5 100644 (file)
@@ -406,10 +406,10 @@ class XmlTypeCheck {
                        $callbackReturn = false;
                }
 
-               if ( $checkIfSafe && isset( $parsedDTD['internal'] ) ) {
-                       if ( !$this->checkDTDIsSafe( $parsedDTD['internal'] ) ) {
-                               $this->wellFormed = false;
-                       }
+               if ( $checkIfSafe && isset( $parsedDTD['internal'] ) &&
+                       !$this->checkDTDIsSafe( $parsedDTD['internal'] )
+               ) {
+                       $this->wellFormed = false;
                }
        }
 
index 9f9cc3c..8f0b539 100644 (file)
@@ -601,22 +601,20 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
                                        [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
                                );
                        // Case C: medium length request with medium replication lag
+                       } elseif ( $lockTSE >= 0 ) {
+                               // Store value as *almost* stale to avoid cache and mutex stampedes
+                               $logicalTTL = self::TTL_SECOND;
+                               $this->logger->info(
+                                       'Lowered set() TTL for {cachekey} due to high read lag.',
+                                       [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
+                               );
                        } else {
-                               if ( $lockTSE >= 0 ) {
-                                       // Store value as *almost* stale to avoid cache and mutex stampedes
-                                       $logicalTTL = self::TTL_SECOND;
-                                       $this->logger->info(
-                                               'Lowered set() TTL for {cachekey} due to high read lag.',
-                                               [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
-                                       );
-                               } else {
-                                       $this->logger->info(
-                                               'Rejected set() for {cachekey} due to high read lag.',
-                                               [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
-                                       );
+                               $this->logger->info(
+                                       'Rejected set() for {cachekey} due to high read lag.',
+                                       [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
+                               );
 
-                                       return true; // no-op the write for being unsafe
-                               }
+                               return true; // no-op the write for being unsafe
                        }
                }
 
index 18961bd..2739205 100644 (file)
@@ -524,20 +524,18 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        $possibleDrivers = $builtinTypes[$dbType];
                        if ( is_string( $possibleDrivers ) ) {
                                $class = $possibleDrivers;
+                       } elseif ( (string)$driver !== '' ) {
+                               if ( !isset( $possibleDrivers[$driver] ) ) {
+                                       throw new InvalidArgumentException( __METHOD__ .
+                                               " type '$dbType' does not support driver '{$driver}'" );
+                               }
+
+                               $class = $possibleDrivers[$driver];
                        } else {
-                               if ( (string)$driver !== '' ) {
-                                       if ( !isset( $possibleDrivers[$driver] ) ) {
-                                               throw new InvalidArgumentException( __METHOD__ .
-                                                       " type '$dbType' does not support driver '{$driver}'" );
-                                       } else {
-                                               $class = $possibleDrivers[$driver];
-                                       }
-                               } else {
-                                       foreach ( $possibleDrivers as $posDriver => $possibleClass ) {
-                                               if ( extension_loaded( $posDriver ) ) {
-                                                       $class = $possibleClass;
-                                                       break;
-                                               }
+                               foreach ( $possibleDrivers as $posDriver => $possibleClass ) {
+                                       if ( extension_loaded( $posDriver ) ) {
+                                               $class = $possibleClass;
+                                               break;
                                        }
                                }
                        }
@@ -644,13 +642,13 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        public function getLBInfo( $name = null ) {
                if ( is_null( $name ) ) {
                        return $this->lbInfo;
-               } else {
-                       if ( array_key_exists( $name, $this->lbInfo ) ) {
-                               return $this->lbInfo[$name];
-                       } else {
-                               return null;
-                       }
                }
+
+               if ( array_key_exists( $name, $this->lbInfo ) ) {
+                       return $this->lbInfo[$name];
+               }
+
+               return null;
        }
 
        public function setLBInfo( $name, $value = null ) {
@@ -3975,17 +3973,15 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                                        "$fname: Flushing an explicit transaction, getting out of sync."
                                );
                        }
-               } else {
-                       if ( !$this->trxLevel ) {
-                               $this->queryLogger->error(
-                                       "$fname: No transaction to commit, something got out of sync." );
-                               return; // nothing to do
-                       } elseif ( $this->trxAutomatic ) {
-                               throw new DBUnexpectedError(
-                                       $this,
-                                       "$fname: Expected mass commit of all peer transactions (DBO_TRX set)."
-                               );
-                       }
+               } elseif ( !$this->trxLevel ) {
+                       $this->queryLogger->error(
+                               "$fname: No transaction to commit, something got out of sync." );
+                       return; // nothing to do
+               } elseif ( $this->trxAutomatic ) {
+                       throw new DBUnexpectedError(
+                               $this,
+                               "$fname: Expected mass commit of all peer transactions (DBO_TRX set)."
+                       );
                }
 
                $this->assertHasConnectionHandle();
@@ -4030,13 +4026,14 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        final public function rollback( $fname = __METHOD__, $flush = '' ) {
                $trxActive = $this->trxLevel;
 
-               if ( $flush !== self::FLUSHING_INTERNAL && $flush !== self::FLUSHING_ALL_PEERS ) {
-                       if ( $this->getFlag( self::DBO_TRX ) ) {
-                               throw new DBUnexpectedError(
-                                       $this,
-                                       "$fname: Expected mass rollback of all peer transactions (DBO_TRX set)."
-                               );
-                       }
+               if ( $flush !== self::FLUSHING_INTERNAL
+                       && $flush !== self::FLUSHING_ALL_PEERS
+                       && $this->getFlag( self::DBO_TRX )
+               ) {
+                       throw new DBUnexpectedError(
+                               $this,
+                               "$fname: Expected mass rollback of all peer transactions (DBO_TRX set)."
+                       );
                }
 
                if ( $trxActive ) {
index 1fd21d0..bd22aca 100644 (file)
@@ -487,10 +487,8 @@ class LoadBalancer implements ILoadBalancer {
                        $this->waitForPos = $pos;
                        // If a generic reader connection was already established, then wait now
                        $i = $this->readIndex;
-                       if ( $i > 0 ) {
-                               if ( !$this->doWait( $i ) ) {
-                                       $this->laggedReplicaMode = true;
-                               }
+                       if ( ( $i > 0 ) && !$this->doWait( $i ) ) {
+                               $this->laggedReplicaMode = true;
                        }
                } finally {
                        // Restore the older position if it was higher since this is used for lag-protection
index aa60242..9a8086f 100644 (file)
@@ -245,13 +245,11 @@ class RedisConnectionPool implements LoggerAwareInterface {
 
                                return false;
                        }
-                       if ( $this->password !== null ) {
-                               if ( !$conn->auth( $this->password ) ) {
-                                       $logger->error(
-                                               'Authentication error connecting to "{redis_server}"',
-                                               [ 'redis_server' => $server ]
-                                       );
-                               }
+                       if ( ( $this->password !== null ) && !$conn->auth( $this->password ) ) {
+                               $logger->error(
+                                       'Authentication error connecting to "{redis_server}"',
+                                       [ 'redis_server' => $server ]
+                               );
                        }
                } catch ( RedisException $e ) {
                        $this->downServers[$server] = time() + self::SERVER_DOWN_TTL;
@@ -364,15 +362,13 @@ class RedisConnectionPool implements LoggerAwareInterface {
         * @return bool Success
         */
        public function reauthenticateConnection( $server, Redis $conn ) {
-               if ( $this->password !== null ) {
-                       if ( !$conn->auth( $this->password ) ) {
-                               $this->logger->error(
-                                       'Authentication error connecting to "{redis_server}"',
-                                       [ 'redis_server' => $server ]
-                               );
+               if ( $this->password !== null && !$conn->auth( $this->password ) ) {
+                       $this->logger->error(
+                               'Authentication error connecting to "{redis_server}"',
+                               [ 'redis_server' => $server ]
+                       );
 
-                               return false;
-                       }
+                       return false;
                }
 
                return true;
index 987239b..acf2c2e 100644 (file)
@@ -225,10 +225,9 @@ class EmailNotification {
                                                && $watchingUser->getId() != $userTalkId
                                                && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges )
                                                && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() )
+                                               && Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] )
                                        ) {
-                                               if ( Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) {
-                                                       $this->compose( $watchingUser, self::WATCHLIST );
-                                               }
+                                               $this->compose( $watchingUser, self::WATCHLIST );
                                        }
                                }
                        }
index b8b706d..f003554 100644 (file)
@@ -338,10 +338,8 @@ class BitmapHandler extends TransformationalImageHandler {
                        }
                        $im->setImageDepth( 8 );
 
-                       if ( $rotation ) {
-                               if ( !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) {
-                                       return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" );
-                               }
+                       if ( $rotation && !$im->rotateImage( new ImagickPixel( 'white' ), 360 - $rotation ) ) {
+                               return $this->getMediaTransformError( $params, "Error rotating $rotation degrees" );
                        }
 
                        if ( $this->isAnimatedImage( $image ) ) {
index 81c63db..9617692 100644 (file)
@@ -132,13 +132,13 @@ class BitmapMetadataHandler {
                                        // Do some special casing for multilingual values.
                                        // Don't discard translations if also as a simple value.
                                        foreach ( $this->metadata[$type] as $itemName => $item ) {
-                                               if ( is_array( $item ) && isset( $item['_type'] ) && $item['_type'] === 'lang' ) {
-                                                       if ( isset( $temp[$itemName] ) && !is_array( $temp[$itemName] ) ) {
-                                                               $default = $temp[$itemName];
-                                                               $temp[$itemName] = $item;
-                                                               $temp[$itemName]['x-default'] = $default;
-                                                               unset( $this->metadata[$type][$itemName] );
-                                                       }
+                                               if ( is_array( $item ) && isset( $item['_type'] ) && $item['_type'] === 'lang' &&
+                                                       isset( $temp[$itemName] ) && !is_array( $temp[$itemName] )
+                                               ) {
+                                                       $default = $temp[$itemName];
+                                                       $temp[$itemName] = $item;
+                                                       $temp[$itemName]['x-default'] = $default;
+                                                       unset( $this->metadata[$type][$itemName] );
                                                }
                                        }
 
index b7745df..4d75d04 100644 (file)
@@ -199,20 +199,16 @@ class SvgHandler extends ImageHandler {
                                $params['physicalWidth'] = $wgSVGMaxSize;
                                $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
                        }
-               } else {
-                       if ( $params['physicalHeight'] > $wgSVGMaxSize ) {
-                               $srcWidth = $image->getWidth( $params['page'] );
-                               $srcHeight = $image->getHeight( $params['page'] );
-                               $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
-                               $params['physicalHeight'] = $wgSVGMaxSize;
-                       }
+               } elseif ( $params['physicalHeight'] > $wgSVGMaxSize ) {
+                       $srcWidth = $image->getWidth( $params['page'] );
+                       $srcHeight = $image->getHeight( $params['page'] );
+                       $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
+                       $params['physicalHeight'] = $wgSVGMaxSize;
                }
                // To prevent the proliferation of thumbnails in languages not present in SVGs, unless
                // explicitly forced by user.
-               if ( isset( $params['targetlang'] ) ) {
-                       if ( !$image->getMatchedLanguage( $params['targetlang'] ) ) {
-                               unset( $params['targetlang'] );
-                       }
+               if ( isset( $params['targetlang'] ) && !$image->getMatchedLanguage( $params['targetlang'] ) ) {
+                       unset( $params['targetlang'] );
                }
 
                return $params;
index 22363bf..124437e 100644 (file)
@@ -1131,13 +1131,11 @@ class Article implements Page {
         * [[MediaWiki:Talkpagetext]]. For Article::view().
         */
        public function showNamespaceHeader() {
-               if ( $this->getTitle()->isTalkPage() ) {
-                       if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
-                               $this->getContext()->getOutput()->wrapWikiMsg(
-                                       "<div class=\"mw-talkpageheader\">\n$1\n</div>",
-                                       [ 'talkpageheader' ]
-                               );
-                       }
+               if ( $this->getTitle()->isTalkPage() && !wfMessage( 'talkpageheader' )->isDisabled() ) {
+                       $this->getContext()->getOutput()->wrapWikiMsg(
+                               "<div class=\"mw-talkpageheader\">\n$1\n</div>",
+                               [ 'talkpageheader' ]
+                       );
                }
        }
 
index f925038..50c7e23 100644 (file)
@@ -380,23 +380,19 @@ class BlockLevelPass {
                                                                $output .= $pendingPTag . '<br />';
                                                                $pendingPTag = false;
                                                                $this->lastParagraph = 'p';
-                                                       } else {
-                                                               if ( $this->lastParagraph !== 'p' ) {
-                                                                       $output .= $this->closeParagraph();
-                                                                       $pendingPTag = '<p>';
-                                                               } else {
-                                                                       $pendingPTag = '</p><p>';
-                                                               }
-                                                       }
-                                               } else {
-                                                       if ( $pendingPTag ) {
-                                                               $output .= $pendingPTag;
-                                                               $pendingPTag = false;
-                                                               $this->lastParagraph = 'p';
                                                        } elseif ( $this->lastParagraph !== 'p' ) {
-                                                               $output .= $this->closeParagraph() . '<p>';
-                                                               $this->lastParagraph = 'p';
+                                                               $output .= $this->closeParagraph();
+                                                               $pendingPTag = '<p>';
+                                                       } else {
+                                                               $pendingPTag = '</p><p>';
                                                        }
+                                               } elseif ( $pendingPTag ) {
+                                                       $output .= $pendingPTag;
+                                                       $pendingPTag = false;
+                                                       $this->lastParagraph = 'p';
+                                               } elseif ( $this->lastParagraph !== 'p' ) {
+                                                       $output .= $this->closeParagraph() . '<p>';
+                                                       $this->lastParagraph = 'p';
                                                }
                                        }
                                }
index a1a784b..0ced8a1 100644 (file)
@@ -1421,13 +1421,12 @@ class Parser {
                 */
                if ( !( $this->mOptions->getDisableContentConversion()
                        || isset( $this->mDoubleUnderscores['nocontentconvert'] ) )
+                       && !$this->mOptions->getInterfaceMessage()
                ) {
-                       if ( !$this->mOptions->getInterfaceMessage() ) {
-                               # The position of the convert() call should not be changed. it
-                               # assumes that the links are all replaced and the only thing left
-                               # is the <nowiki> mark.
-                               $text = $this->getTargetLanguage()->convert( $text );
-                       }
+                       # The position of the convert() call should not be changed. it
+                       # assumes that the links are all replaced and the only thing left
+                       # is the <nowiki> mark.
+                       $text = $this->getTargetLanguage()->convert( $text );
                }
 
                $text = $this->mStripState->unstripNoWiki( $text );
@@ -1767,10 +1766,8 @@ class Parser {
                                                // if $firstsingleletterword is set, we don't
                                                // look at the other options, so we can bail early.
                                                break;
-                                       } else {
-                                               if ( $firstmultiletterword == -1 ) {
-                                                       $firstmultiletterword = $i;
-                                               }
+                                       } elseif ( $firstmultiletterword == -1 ) {
+                                               $firstmultiletterword = $i;
                                        }
                                }
                        }
@@ -2578,10 +2575,10 @@ class Parser {
                 * Some of these require message or data lookups and can be
                 * expensive to check many times.
                 */
-               if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$parser, &$this->mVarCache ] ) ) {
-                       if ( isset( $this->mVarCache[$index] ) ) {
-                               return $this->mVarCache[$index];
-                       }
+               if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$parser, &$this->mVarCache ] )
+                       && isset( $this->mVarCache[$index] )
+               ) {
+                       return $this->mVarCache[$index];
                }
 
                $ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() );
@@ -5367,10 +5364,8 @@ class Parser {
                                                                        if ( $paramName === 'no-link' ) {
                                                                                $value = true;
                                                                        }
-                                                                       if ( $paramName === 'link-url' ) {
-                                                                               if ( $this->mOptions->getExternalLinkTarget() ) {
-                                                                                       $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
-                                                                               }
+                                                                       if ( ( $paramName === 'link-url' ) && $this->mOptions->getExternalLinkTarget() ) {
+                                                                               $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
                                                                        }
                                                                }
                                                                break;
@@ -5711,15 +5706,15 @@ class Parser {
                        if ( $sectionIndex == 0 ) {
                                if ( $mode === 'get' ) {
                                        return '';
-                               } else {
-                                       return $newText;
                                }
+
+                               return $newText;
                        } else {
                                if ( $mode === 'get' ) {
                                        return $newText;
-                               } else {
-                                       return $text;
                                }
+
+                               return $text;
                        }
                }
 
@@ -6334,10 +6329,8 @@ class Parser {
         */
        public static function stripOuterParagraph( $html ) {
                $m = [];
-               if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $html, $m ) ) {
-                       if ( strpos( $m[1], '</p>' ) === false ) {
-                               $html = $m[1];
-                       }
+               if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $html, $m ) && strpos( $m[1], '</p>' ) === false ) {
+                       $html = $m[1];
                }
 
                return $html;
index 0aa58c1..518846c 100644 (file)
@@ -578,10 +578,8 @@ class Sanitizer {
                                                                        $badtag = true;
                                                                }
                                                        }
-                                               } else {
-                                                       if ( $t == 'table' ) {
-                                                               $tagstack = array_pop( $tablestack );
-                                                       }
+                                               } elseif ( $t == 'table' ) {
+                                                       $tagstack = array_pop( $tablestack );
                                                }
                                                $newparams = '';
                                        } else {
index 8ab7c0c..839948d 100644 (file)
@@ -1160,11 +1160,9 @@ MESSAGE;
                                // Use a linebreak between module script and state script (T162719)
                                $out = $this->ensureNewline( $out ) . $stateScript;
                        }
-               } else {
-                       if ( $states ) {
-                               $this->errors[] = 'Problematic modules: '
-                                       . self::encodeJsonForScript( $states );
-                       }
+               } elseif ( $states ) {
+                       $this->errors[] = 'Problematic modules: '
+                               . self::encodeJsonForScript( $states );
                }
 
                return $out;
index 84477ca..ec408c7 100644 (file)
@@ -450,19 +450,17 @@ class ResourceLoaderClientHtml {
                                                // Decide whether to use 'style' or 'script' element
                                                if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
                                                        $chunk = Html::linkedStyle( $url );
+                                               } elseif ( $context->getRaw() || $isRaw ) {
+                                                       $chunk = Html::element( 'script', [
+                                                               // In SpecialJavaScriptTest, QUnit must load synchronous
+                                                               'async' => !isset( $extraQuery['sync'] ),
+                                                               'src' => $url
+                                                       ] );
                                                } else {
-                                                       if ( $context->getRaw() || $isRaw ) {
-                                                               $chunk = Html::element( 'script', [
-                                                                       // In SpecialJavaScriptTest, QUnit must load synchronous
-                                                                       'async' => !isset( $extraQuery['sync'] ),
-                                                                       'src' => $url
-                                                               ] );
-                                                       } else {
-                                                               $chunk = ResourceLoader::makeInlineScript(
-                                                                       Xml::encodeJsCall( 'mw.loader.load', [ $url ] ),
-                                                                       $nonce
-                                                               );
-                                                       }
+                                                       $chunk = ResourceLoader::makeInlineScript(
+                                                               Xml::encodeJsCall( 'mw.loader.load', [ $url ] ),
+                                                               $nonce
+                                                       );
                                                }
 
                                                if ( $group == 'noscript' ) {
index 02247bd..8fe35f0 100644 (file)
@@ -264,28 +264,26 @@ abstract class BaseTemplate extends QuickTemplate {
                                        $boxes[$boxName]['content'] = $content;
                                }
                        }
-               } else {
-                       if ( $hookContents ) {
-                               $boxes['TOOLBOXEND'] = [
-                                       'id' => 'p-toolboxend',
-                                       'header' => $boxes['TOOLBOX']['header'],
-                                       'generated' => false,
-                                       'content' => "<ul>{$hookContents}</ul>",
-                               ];
-                               // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
-                               $boxes2 = [];
-                               foreach ( $boxes as $key => $box ) {
-                                       if ( $key === 'TOOLBOXEND' ) {
-                                               continue;
-                                       }
-                                       $boxes2[$key] = $box;
-                                       if ( $key === 'TOOLBOX' ) {
-                                               $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
-                                       }
+               } elseif ( $hookContents ) {
+                       $boxes['TOOLBOXEND'] = [
+                               'id' => 'p-toolboxend',
+                               'header' => $boxes['TOOLBOX']['header'],
+                               'generated' => false,
+                               'content' => "<ul>{$hookContents}</ul>",
+                       ];
+                       // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
+                       $boxes2 = [];
+                       foreach ( $boxes as $key => $box ) {
+                               if ( $key === 'TOOLBOXEND' ) {
+                                       continue;
+                               }
+                               $boxes2[$key] = $box;
+                               if ( $key === 'TOOLBOX' ) {
+                                       $boxes2['TOOLBOXEND'] = $boxes['TOOLBOXEND'];
                                }
-                               $boxes = $boxes2;
-                               // END hack
                        }
+                       $boxes = $boxes2;
+                       // END hack
                }
 
                return $boxes;
index a9c0993..8f45f28 100644 (file)
@@ -389,17 +389,15 @@ class SkinTemplate extends Skin {
                $tpl->set( 'credits', false );
                $tpl->set( 'numberofwatchingusers', false );
                if ( $title->exists() ) {
-                       if ( $out->isArticle() ) {
-                               if ( $this->isRevisionCurrent() ) {
-                                       if ( $wgMaxCredits != 0 ) {
-                                               /** @var CreditsAction $action */
-                                               $action = Action::factory(
-                                                       'credits', $this->getWikiPage(), $this->getContext() );
-                                               $tpl->set( 'credits',
-                                                       $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
-                                       } else {
-                                               $tpl->set( 'lastmod', $this->lastModified() );
-                                       }
+                       if ( $out->isArticle() && $this->isRevisionCurrent() ) {
+                               if ( $wgMaxCredits != 0 ) {
+                                       /** @var CreditsAction $action */
+                                       $action = Action::factory(
+                                               'credits', $this->getWikiPage(), $this->getContext() );
+                                       $tpl->set( 'credits',
+                                               $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
+                               } else {
+                                       $tpl->set( 'lastmod', $this->lastModified() );
                                }
                        }
                        if ( $out->showsCopyright() ) {
index 055a6e2..08a7fde 100644 (file)
@@ -267,14 +267,10 @@ class SpecialContributions extends IncludableSpecialPage {
                                $message = 'sp-contributions-footer';
                        }
 
-                       if ( $message ) {
-                               if ( !$this->including() ) {
-                                       if ( !$this->msg( $message, $target )->isDisabled() ) {
-                                               $out->wrapWikiMsg(
-                                                       "<div class='mw-contributions-footer'>\n$1\n</div>",
-                                                       [ $message, $target ] );
-                                       }
-                               }
+                       if ( $message && !$this->including() && !$this->msg( $message, $target )->isDisabled() ) {
+                               $out->wrapWikiMsg(
+                                       "<div class='mw-contributions-footer'>\n$1\n</div>",
+                                       [ $message, $target ] );
                        }
                }
        }
index a985bcc..aaa405a 100644 (file)
@@ -391,10 +391,8 @@ class SpecialImport extends SpecialPage {
                                        Xml::closeElement( 'form' ) .
                                        Xml::closeElement( 'fieldset' )
                        );
-               } else {
-                       if ( empty( $this->importSources ) ) {
-                               $out->addWikiMsg( 'importnosources' );
-                       }
+               } elseif ( empty( $this->importSources ) ) {
+                       $out->addWikiMsg( 'importnosources' );
                }
 
                if ( $user->isAllowed( 'import' ) && !empty( $this->importSources ) ) {
index a520396..f27a736 100644 (file)
@@ -243,14 +243,12 @@ class SpecialSearch extends SpecialPage {
                        $this->namespaces = $nslist;
                } elseif ( $profile === 'advanced' ) {
                        $this->namespaces = $nslist;
+               } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
+                       $this->namespaces = $profiles[$profile]['namespaces'];
                } else {
-                       if ( isset( $profiles[$profile]['namespaces'] ) ) {
-                               $this->namespaces = $profiles[$profile]['namespaces'];
-                       } else {
-                               // Unknown profile requested
-                               $profile = 'default';
-                               $this->namespaces = $profiles['default']['namespaces'];
-                       }
+                       // Unknown profile requested
+                       $profile = 'default';
+                       $this->namespaces = $profiles['default']['namespaces'];
                }
 
                $this->fulltext = $request->getVal( 'fulltext' );
index 5a1b8fb..dcc35fc 100644 (file)
@@ -191,11 +191,9 @@ class SpecialUpload extends SpecialPage {
                $this->loadRequest();
 
                # Unsave the temporary file in case this was a cancelled upload
-               if ( $this->mCancelUpload ) {
-                       if ( !$this->unsaveUploadedFile() ) {
-                               # Something went wrong, so unsaveUploadedFile showed a warning
-                               return;
-                       }
+               if ( $this->mCancelUpload && !$this->unsaveUploadedFile() ) {
+                       # Something went wrong, so unsaveUploadedFile showed a warning
+                       return;
                }
 
                # Process upload or show a form
index b48e858..18c10bf 100644 (file)
@@ -200,29 +200,27 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        && ( $hidetrans || !$tlRes->numRows() )
                        && ( $hideimages || !$ilRes->numRows() )
                ) {
-                       if ( $level == 0 ) {
-                               if ( !$this->including() ) {
-                                       $out->addHTML( $this->whatlinkshereForm() );
-
-                                       // Show filters only if there are links
-                                       if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
-                                               $out->addHTML( $this->getFilterPanel() );
-                                       }
-                                       $msgKey = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
-                                       $link = $this->getLinkRenderer()->makeLink(
-                                               $this->target,
-                                               null,
-                                               [],
-                                               $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
-                                       );
-
-                                       $errMsg = $this->msg( $msgKey )
-                                               ->params( $this->target->getPrefixedText() )
-                                               ->rawParams( $link )
-                                               ->parseAsBlock();
-                                       $out->addHTML( $errMsg );
-                                       $out->setStatusCode( 404 );
+                       if ( $level == 0 && !$this->including() ) {
+                               $out->addHTML( $this->whatlinkshereForm() );
+
+                               // Show filters only if there are links
+                               if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
+                                       $out->addHTML( $this->getFilterPanel() );
                                }
+                               $msgKey = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
+                               $link = $this->getLinkRenderer()->makeLink(
+                                       $this->target,
+                                       null,
+                                       [],
+                                       $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
+                               );
+
+                               $errMsg = $this->msg( $msgKey )
+                                       ->params( $this->target->getPrefixedText() )
+                                       ->rawParams( $link )
+                                       ->parseAsBlock();
+                               $out->addHTML( $errMsg );
+                               $out->setStatusCode( 404 );
                        }
 
                        return;
@@ -280,27 +278,25 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                }
                $lb->execute();
 
-               if ( $level == 0 ) {
-                       if ( !$this->including() ) {
-                               $out->addHTML( $this->whatlinkshereForm() );
-                               $out->addHTML( $this->getFilterPanel() );
+               if ( $level == 0 && !$this->including() ) {
+                       $out->addHTML( $this->whatlinkshereForm() );
+                       $out->addHTML( $this->getFilterPanel() );
 
-                               $link = $this->getLinkRenderer()->makeLink(
-                                       $this->target,
-                                       null,
-                                       [],
-                                       $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
-                               );
+                       $link = $this->getLinkRenderer()->makeLink(
+                               $this->target,
+                               null,
+                               [],
+                               $this->target->isRedirect() ? [ 'redirect' => 'no' ] : []
+                       );
 
-                               $msg = $this->msg( 'linkshere' )
-                                       ->params( $this->target->getPrefixedText() )
-                                       ->rawParams( $link )
-                                       ->parseAsBlock();
-                               $out->addHTML( $msg );
+                       $msg = $this->msg( 'linkshere' )
+                               ->params( $this->target->getPrefixedText() )
+                               ->rawParams( $link )
+                               ->parseAsBlock();
+                       $out->addHTML( $msg );
 
-                               $prevnext = $this->getPrevNext( $prevId, $nextId );
-                               $out->addHTML( $prevnext );
-                       }
+                       $prevnext = $this->getPrevNext( $prevId, $nextId );
+                       $out->addHTML( $prevnext );
                }
                $out->addHTML( $this->listStart( $level ) );
                foreach ( $rows as $row ) {
@@ -321,10 +317,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
 
                $out->addHTML( $this->listEnd() );
 
-               if ( $level == 0 ) {
-                       if ( !$this->including() ) {
-                               $out->addHTML( $prevnext );
-                       }
+               if ( $level == 0 && !$this->including() ) {
+                       $out->addHTML( $prevnext );
                }
        }
 
index 2b8d1d5..71cf787 100644 (file)
@@ -191,10 +191,8 @@ class BlockListPager extends TablePager {
                        case 'ipb_params':
                                $properties = [];
 
-                               if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
-                                       if ( $row->ipb_sitewide ) {
-                                               $properties[] = htmlspecialchars( $msg['blocklist-editing-sitewide'] );
-                                       }
+                               if ( $this->getConfig()->get( 'EnablePartialBlocks' ) && $row->ipb_sitewide ) {
+                                       $properties[] = htmlspecialchars( $msg['blocklist-editing-sitewide'] );
                                }
 
                                if ( !$row->ipb_sitewide && $this->restrictions ) {
index 486b0ec..ea55568 100644 (file)
@@ -269,10 +269,8 @@ class ImageListPager extends TablePager {
                                }
                        }
                        $fields['top'] = $dbr->addQuotes( 'no' );
-               } else {
-                       if ( $this->mShowAll ) {
-                               $fields['top'] = $dbr->addQuotes( 'yes' );
-                       }
+               } elseif ( $this->mShowAll ) {
+                       $fields['top'] = $dbr->addQuotes( 'yes' );
                }
                $fields['thumb'] = $prefix . '_name';
 
@@ -382,14 +380,12 @@ class ImageListPager extends TablePager {
                                        $resultArray[] = $topRes2;
                                        $topRes2 = $res2->next();
                                }
+                       } elseif ( !$ascending ) {
+                               $resultArray[] = $topRes2;
+                               $topRes2 = $res2->next();
                        } else {
-                               if ( !$ascending ) {
-                                       $resultArray[] = $topRes2;
-                                       $topRes2 = $res2->next();
-                               } else {
-                                       $resultArray[] = $topRes1;
-                                       $topRes1 = $res1->next();
-                               }
+                               $resultArray[] = $topRes1;
+                               $topRes1 = $res1->next();
                        }
                }
 
index 4e93382..abc98ba 100644 (file)
@@ -40,10 +40,10 @@ class RemexCompatFormatter extends HtmlFormatter {
 
                $name = $node->name;
                $attrs = $node->attrs;
-               if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0 ) {
-                       if ( strspn( $contents, "\t\n\f\r " ) === strlen( $contents ) ) {
-                               return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
-                       }
+               if ( isset( self::$markedEmptyElements[$name] ) && $attrs->count() === 0
+                       && strspn( $contents, "\t\n\f\r " ) === strlen( $contents )
+               ) {
+                       return "<{$name} class=\"mw-empty-elt\">$contents</{$name}>";
                }
 
                $s = "<$name";
index e06bfb5..adbea89 100644 (file)
@@ -421,10 +421,8 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
 
                # Can't make a link to a namespace alone... "empty" local links can only be
                # self-links with a fragment identifier.
-               if ( $dbkey == '' && $parts['interwiki'] === '' ) {
-                       if ( $parts['namespace'] != NS_MAIN ) {
-                               throw new MalformedTitleException( 'title-invalid-empty', $text );
-                       }
+               if ( $dbkey == '' && $parts['interwiki'] === '' && $parts['namespace'] != NS_MAIN ) {
+                       throw new MalformedTitleException( 'title-invalid-empty', $text );
                }
 
                // Allow IPv6 usernames to start with '::' by canonicalizing IPv6 titles.
index d00ad97..9e92e78 100644 (file)
@@ -1078,10 +1078,8 @@ abstract class UploadBase {
                $props = $this->mFileProps;
                $error = null;
                Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] );
-               if ( $error ) {
-                       if ( !is_array( $error ) ) {
-                               $error = [ $error ];
-                       }
+               if ( $error && !is_array( $error ) ) {
+                       $error = [ $error ];
                }
                return $error;
        }
@@ -1916,10 +1914,8 @@ abstract class UploadBase {
                                $output = true; # if there's no output, return true
                        } elseif ( $msgPattern ) {
                                $groups = [];
-                               if ( preg_match( $msgPattern, $output, $groups ) ) {
-                                       if ( $groups[1] ) {
-                                               $output = $groups[1];
-                                       }
+                               if ( preg_match( $msgPattern, $output, $groups ) && $groups[1] ) {
+                                       $output = $groups[1];
                                }
                        }
 
index aa31a5b..7d69fe1 100644 (file)
@@ -162,12 +162,10 @@ class UploadStash {
                        );
                }
 
-               if ( !$noAuth ) {
-                       if ( $this->fileMetadata[$key]['us_user'] != $this->userId ) {
-                               throw new UploadStashWrongOwnerException(
-                                       wfMessage( 'uploadstash-wrong-owner', $key )
-                               );
-                       }
+               if ( !$noAuth && $this->fileMetadata[$key]['us_user'] != $this->userId ) {
+                       throw new UploadStashWrongOwnerException(
+                               wfMessage( 'uploadstash-wrong-owner', $key )
+                       );
                }
 
                return $this->files[$key];
index fa74cb3..c191c70 100644 (file)
@@ -1405,10 +1405,10 @@ class User implements IDBAccessObject, UserIdentity {
        public function trackBlockWithCookie() {
                $block = $this->getBlock();
 
-               if ( $block && $this->getRequest()->getCookie( 'BlockID' ) === null ) {
-                       if ( $block->shouldTrackWithCookie( $this->isAnon() ) ) {
-                               $block->setCookie( $this->getRequest()->response() );
-                       }
+               if ( $block && $this->getRequest()->getCookie( 'BlockID' ) === null
+                       && $block->shouldTrackWithCookie( $this->isAnon() )
+               ) {
+                       $block->setCookie( $this->getRequest()->response() );
                }
        }
 
@@ -4424,10 +4424,8 @@ class User implements IDBAccessObject, UserIdentity {
                                        [ 'LOCK IN SHARE MODE' ]
                                );
                                $loaded = false;
-                               if ( $this->mId ) {
-                                       if ( $this->loadFromDatabase( self::READ_LOCKING ) ) {
-                                               $loaded = true;
-                                       }
+                               if ( $this->mId && $this->loadFromDatabase( self::READ_LOCKING ) ) {
+                                       $loaded = true;
                                }
                                if ( !$loaded ) {
                                        throw new MWException( $fname . ": hit a key conflict attempting " .
index 3ebc94a..6094f41 100644 (file)
@@ -445,11 +445,9 @@ class WatchedItemQueryService {
 
                $conds = array_merge( $conds, $this->getStartEndConds( $db, $options ) );
 
-               if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) {
-                       if ( $db->getType() === 'mysql' ) {
-                               // This is an index optimization for mysql
-                               $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' );
-                       }
+               if ( !isset( $options['start'] ) && !isset( $options['end'] ) && $db->getType() === 'mysql' ) {
+                       // This is an index optimization for mysql
+                       $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' );
                }
 
                $conds = array_merge( $conds, $this->getUserRelatedConds( $db, $user, $options ) );
index 4730005..3c7cb14 100644 (file)
@@ -40,10 +40,10 @@ class FirejailCommandIntegrationTest extends PHPUnit\Framework\TestCase {
         * @dataProvider provideExecute
         */
        public function testExecute( $testCommand, $flag ) {
-               if ( preg_match( '/^sudo /', $testCommand ) ) {
-                       if ( Shell::command( 'sudo', '-n', 'ls', '/' )->execute()->getExitCode() ) {
-                               $this->markTestSkipped( 'need passwordless sudo' );
-                       }
+               if ( preg_match( '/^sudo /', $testCommand )
+                       && Shell::command( 'sudo', '-n', 'ls', '/' )->execute()->getExitCode()
+               ) {
+                       $this->markTestSkipped( 'need passwordless sudo' );
                }
 
                $command = new FirejailCommand( 'firejail' );
index 1ddc254..5246e36 100644 (file)
@@ -528,12 +528,10 @@ class RevisionStoreTest extends MediaWikiTestCase {
                                'old_text' => 'Hello World',
                                'old_flags' => 'utf-8',
                        ];
-               } else {
-                       if ( !isset( $row['content'] ) && isset( $array['old_text'] ) ) {
-                               $row['content'] = [
-                                       'main' => new WikitextContent( $array['old_text'] ),
-                               ];
-                       }
+               } elseif ( !isset( $row['content'] ) && isset( $array['old_text'] ) ) {
+                       $row['content'] = [
+                               'main' => new WikitextContent( $array['old_text'] ),
+                       ];
                }
 
                return (object)$row;
index 4c64291..2453353 100644 (file)
@@ -500,10 +500,8 @@ class ApiStructureTest extends MediaWikiTestCase {
                                                if ( $value instanceof $type ) {
                                                        return;
                                                }
-                                       } else {
-                                               if ( gettype( $value ) === $type ) {
-                                                       return;
-                                               }
+                                       } elseif ( gettype( $value ) === $type ) {
+                                               return;
                                        }
                                } else {
                                        // Array whose values have specified types, recurse
index 75e21ae..2ae6a78 100644 (file)
@@ -112,14 +112,12 @@ class AutoLoaderStructureTest extends MediaWikiTestCase {
                                // 'class Foo {}'
                                $class = $fileNamespace . $match['class'];
                                $classesInFile[$class] = true;
+                       } elseif ( !empty( $match['original'] ) ) {
+                               // 'class_alias( "Foo", "Bar" );'
+                               $aliasesInFile[$match['alias']] = $match['original'];
                        } else {
-                               if ( !empty( $match['original'] ) ) {
-                                       // 'class_alias( "Foo", "Bar" );'
-                                       $aliasesInFile[$match['alias']] = $match['original'];
-                               } else {
-                                       // 'class_alias( Foo::class, "Bar" );'
-                                       $aliasesInFile[$match['aliasString']] = $fileNamespace . $match['originalStatic'];
-                               }
+                               // 'class_alias( Foo::class, "Bar" );'
+                               $aliasesInFile[$match['aliasString']] = $fileNamespace . $match['originalStatic'];
                        }
                }