Merge "composer.json, require ext-fileinfo"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 24 Oct 2018 23:35:56 +0000 (23:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 24 Oct 2018 23:35:56 +0000 (23:35 +0000)
69 files changed:
RELEASE-NOTES-1.32
RELEASE-NOTES-1.33
includes/DefaultSettings.php
includes/MediaWiki.php
includes/MediaWikiServices.php
includes/OutputPage.php
includes/api/ApiParse.php
includes/api/ApiQueryRevisionsBase.php
includes/api/ApiRollback.php
includes/auth/AuthManagerAuthPlugin.php
includes/cache/BacklinkCache.php
includes/cache/localisation/LCStoreCDB.php
includes/cache/localisation/LCStoreStaticArray.php
includes/changes/ChangesListBooleanFilter.php
includes/changes/ChangesListFilterGroup.php
includes/changetags/ChangeTags.php
includes/debug/logger/monolog/KafkaHandler.php
includes/htmlform/fields/HTMLFormFieldWithButton.php
includes/htmlform/fields/HTMLMultiSelectField.php
includes/http/MWHttpRequest.php
includes/import/WikiImporter.php
includes/installer/DatabaseUpdater.php
includes/installer/Installer.php
includes/installer/MysqlInstaller.php
includes/installer/WebInstaller.php
includes/installer/WebInstallerExistingWiki.php
includes/installer/WebInstallerOptions.php
includes/jobqueue/JobQueueGroup.php
includes/libs/CSSMin.php
includes/libs/Cookie.php
includes/libs/CryptRand.php
includes/libs/JavaScriptMinifier.php
includes/libs/mime/MimeAnalyzer.php
includes/libs/objectcache/BagOStuff.php
includes/libs/objectcache/RedisBagOStuff.php
includes/libs/rdbms/database/DatabaseMssql.php
includes/libs/rdbms/lbfactory/LBFactoryMulti.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/logging/LogFormatter.php
includes/logging/LogPage.php
includes/media/IPTC.php
includes/media/MediaHandler.php
includes/objectcache/ObjectCache.php
includes/parser/DateFormatter.php
includes/parser/ParserOutput.php
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
includes/preferences/DefaultPreferencesFactory.php
includes/registration/ExtensionProcessor.php
includes/resourceloader/ResourceLoader.php
includes/search/SearchEngine.php
includes/shell/Shell.php
includes/site/HashSiteStore.php
includes/skins/BaseTemplate.php
includes/skins/Skin.php
includes/specialpage/ChangesListSpecialPage.php
includes/specialpage/SpecialPageFactory.php
includes/specials/SpecialGoToInterwiki.php
includes/specials/SpecialMediaStatistics.php
includes/specials/SpecialUserrights.php
includes/specials/formfields/UploadSourceField.php
includes/upload/UploadBase.php
includes/user/User.php
includes/utils/MWCryptRand.php
includes/utils/MWFileProps.php
includes/widget/search/InterwikiSearchResultSetWidget.php
languages/ConverterRule.php
tests/phpunit/includes/MediaWikiServicesTest.php
tests/phpunit/includes/OutputPageTest.php

index 16b7ffa..8ccc9c2 100644 (file)
@@ -60,6 +60,10 @@ production.
 * $wgPopularPasswordFile — The location of the default popular passwords file
   has been moved to be in line with other non-PHP files used by libraries and
   classes.
+* $wgEnableImageWhitelist is now disabled by default, as it opens up a hole for
+  potential privacy leaks by administrators. You can check
+  "MediaWiki:External image whitelist" on your wiki to see whether the feature
+  was ever used, and whether it needs to be re-enabled.
 
 ==== Removed configuration ====
 * $wgEnableAPI and $wgEnableWriteAPI – These settings, deprecated in 1.31,
index 387fe5a..e3bd208 100644 (file)
@@ -8,6 +8,9 @@ production.
 === Configuration changes in 1.33 ===
 
 ==== New configuration ====
+* $wgEnablePartialBlocks – This enables the Partial Blocks feature, which gives
+  accounts with block permissions the ability to block users, IPs, and IP ranges
+  from editing specific pages, while allowing them to edit the rest of the wiki.
 * …
 
 ==== Changed configuration ====
index 731abb5..82dbecf 100644 (file)
@@ -4245,8 +4245,10 @@ $wgAllowExternalImagesFrom = '';
  *
  * Set this to true to enable the on-wiki whitelist (MediaWiki:External image whitelist)
  * Or false to disable it
+ *
+ * @since 1.14
  */
-$wgEnableImageWhitelist = true;
+$wgEnableImageWhitelist = false;
 
 /**
  * A different approach to the above: simply allow the "<img>" tag to be used.
index bc57637..12b6638 100644 (file)
@@ -43,7 +43,7 @@ class MediaWiki {
        private $config;
 
        /**
-        * @var String Cache what action this request is
+        * @var string Cache what action this request is
         */
        private $action;
 
index 0acd55a..f3ca7d4 100644 (file)
@@ -518,6 +518,7 @@ class MediaWikiServices extends ServiceContainer {
         * @return CryptRand
         */
        public function getCryptRand() {
+               wfDeprecated( __METHOD__, '1.32' );
                return $this->getService( 'CryptRand' );
        }
 
index 3a0a529..ca3f6a3 100644 (file)
@@ -1758,6 +1758,7 @@ class OutputPage extends ContextSource {
         *    or else addWikiTextAsContent() if $interface is false.
         */
        public function addWikiText( $text, $linestart = true, $interface = true ) {
+               wfDeprecated( __METHOD__, '1.32' );
                $title = $this->getTitle();
                if ( !$title ) {
                        throw new MWException( 'Title is null' );
@@ -1936,6 +1937,10 @@ class OutputPage extends ContextSource {
        ) {
                global $wgParser;
 
+               if ( !$tidy ) {
+                       wfDeprecated( 'disabling tidy', '1.32' );
+               }
+
                $popts = $this->parserOptions();
                $oldTidy = $popts->setTidy( $tidy );
                $popts->setInterfaceMessage( (bool)$interface );
@@ -4110,8 +4115,8 @@ class OutputPage extends ContextSource {
         * Helper function to setup the PHP implementation of OOUI to use in this request.
         *
         * @since 1.26
-        * @param String $skinName The Skin name to determine the correct OOUI theme
-        * @param String $dir Language direction
+        * @param string $skinName The Skin name to determine the correct OOUI theme
+        * @param string $dir Language direction
         */
        public static function setupOOUI( $skinName = 'default', $dir = 'ltr' ) {
                $themes = ResourceLoaderOOUIModule::getSkinThemeMap();
index a78cb7f..148ac67 100644 (file)
@@ -625,7 +625,7 @@ class ApiParse extends ApiBase {
         * This mimicks the behavior of EditPage in formatting a summary
         *
         * @param Title $title of the page being parsed
-        * @param Array $params the API parameters of the request
+        * @param array $params The API parameters of the request
         * @return Content|bool
         */
        private function formatSummary( $title, $params ) {
index c9f528c..c00010a 100644 (file)
@@ -169,11 +169,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                        $this->limit = 1;
                                }
                        }
-                       if ( isset( $params['section'] ) ) {
-                               $this->section = $params['section'];
-                       } else {
-                               $this->section = false;
-                       }
+                       $this->section = $params['section'] ?? false;
                }
 
                $userMax = $this->parseContent ? 1 : ( $smallLimit ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 );
index d2ff790..c9ff260 100644 (file)
@@ -69,10 +69,7 @@ class ApiRollback extends ApiBase {
                        $this->dieStatus( $this->errorArrayToStatus( $retval, $user ) );
                }
 
-               $watch = 'preferences';
-               if ( isset( $params['watchlist'] ) ) {
-                       $watch = $params['watchlist'];
-               }
+               $watch = $params['watchlist'] ?? 'preferences';
 
                // Watch pages
                $this->setWatch( $watch, $titleObj, 'watchrollback' );
index 01d992f..008639c 100644 (file)
@@ -79,11 +79,7 @@ class AuthManagerAuthPlugin extends \AuthPlugin {
        }
 
        public function getDomain() {
-               if ( isset( $this->domain ) ) {
-                       return $this->domain;
-               } else {
-                       return 'invaliddomain';
-               }
+               return $this->domain ?? 'invaliddomain';
        }
 
        public function validDomain( $domain ) {
index 48809d0..1407271 100644 (file)
@@ -567,7 +567,7 @@ class BacklinkCache {
        /**
         * Returns check key for the backlinks cache for a particular title
         *
-        * @return String
+        * @return string
         */
        private function makeCheckKey() {
                return $this->wanCache->makeKey(
index 78a4863..246a3dd 100644 (file)
@@ -50,11 +50,7 @@ class LCStoreCDB implements LCStore {
        function __construct( $conf = [] ) {
                global $wgCacheDirectory;
 
-               if ( isset( $conf['directory'] ) ) {
-                       $this->directory = $conf['directory'];
-               } else {
-                       $this->directory = $wgCacheDirectory;
-               }
+               $this->directory = $conf['directory'] ?? $wgCacheDirectory;
        }
 
        public function get( $code, $key ) {
index 3b6da73..c5a2512 100644 (file)
@@ -41,11 +41,7 @@ class LCStoreStaticArray implements LCStore {
        public function __construct( $conf = [] ) {
                global $wgCacheDirectory;
 
-               if ( isset( $conf['directory'] ) ) {
-                       $this->directory = $conf['directory'];
-               } else {
-                       $this->directory = $wgCacheDirectory;
-               }
+               $this->directory = $conf['directory'] ?? $wgCacheDirectory;
        }
 
        public function startWrite( $code ) {
index c781d71..5bb1db9 100644 (file)
@@ -112,11 +112,7 @@ class ChangesListBooleanFilter extends ChangesListFilter {
                        $this->showHide = $filterDefinition['showHide'];
                }
 
-               if ( isset( $filterDefinition['isReplacedInStructuredUi'] ) ) {
-                       $this->isReplacedInStructuredUi = $filterDefinition['isReplacedInStructuredUi'];
-               } else {
-                       $this->isReplacedInStructuredUi = false;
-               }
+               $this->isReplacedInStructuredUi = $filterDefinition['isReplacedInStructuredUi'] ?? false;
 
                if ( isset( $filterDefinition['default'] ) ) {
                        $this->setDefault( $filterDefinition['default'] );
@@ -128,11 +124,7 @@ class ChangesListBooleanFilter extends ChangesListFilter {
                        $this->queryCallable = $filterDefinition['queryCallable'];
                }
 
-               if ( isset( $filterDefinition['activeValue'] ) ) {
-                       $this->activeValue = $filterDefinition['activeValue'];
-               } else {
-                       $this->activeValue = true;
-               }
+               $this->activeValue = $filterDefinition['activeValue'] ?? true;
        }
 
        /**
index 9d30537..deec915 100644 (file)
@@ -174,11 +174,7 @@ abstract class ChangesListFilterGroup {
                }
 
                $this->type = $groupDefinition['type'];
-               if ( isset( $groupDefinition['priority'] ) ) {
-                       $this->priority = $groupDefinition['priority'];
-               } else {
-                       $this->priority = self::DEFAULT_PRIORITY;
-               }
+               $this->priority = $groupDefinition['priority'] ?? self::DEFAULT_PRIORITY;
 
                $this->isFullCoverage = $groupDefinition['isFullCoverage'];
 
index 1d303c7..b28983f 100644 (file)
@@ -351,13 +351,15 @@ class ChangeTags {
                                foreach ( $tagsToAdd as $tag ) {
                                        $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag );
                                }
-
-                               $dbw->update(
-                                       'change_tag_def',
-                                       [ 'ctd_count = ctd_count + 1' ],
-                                       [ 'ctd_name' => $tagsToAdd ],
-                                       __METHOD__
-                               );
+                               // T207881: update the counts at the end of the transaction
+                               $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) {
+                                       $dbw->update(
+                                               'change_tag_def',
+                                               [ 'ctd_count = ctd_count + 1' ],
+                                               [ 'ctd_name' => $tagsToAdd ],
+                                               __METHOD__
+                                       );
+                               } );
                        }
 
                        $tagsRows = [];
@@ -408,18 +410,21 @@ class ChangeTags {
                                );
                                $dbw->delete( 'change_tag', $conds, __METHOD__ );
                                if ( $dbw->affectedRows() && $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
-                                       $dbw->update(
-                                               'change_tag_def',
-                                               [ 'ctd_count = ctd_count - 1' ],
-                                               [ 'ctd_name' => $tag ],
-                                               __METHOD__
-                                       );
-
-                                       $dbw->delete(
-                                               'change_tag_def',
-                                               [ 'ctd_name' => $tag, 'ctd_count' => 0, 'ctd_user_defined' => 0 ],
-                                               __METHOD__
-                                       );
+                                       // T207881: update the counts at the end of the transaction
+                                       $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag ) {
+                                               $dbw->update(
+                                                       'change_tag_def',
+                                                       [ 'ctd_count = ctd_count - 1' ],
+                                                       [ 'ctd_name' => $tag ],
+                                                       __METHOD__
+                                               );
+
+                                               $dbw->delete(
+                                                       'change_tag_def',
+                                                       [ 'ctd_name' => $tag, 'ctd_count' => 0, 'ctd_user_defined' => 0 ],
+                                                       __METHOD__
+                                               );
+                                       } );
                                }
                        }
                }
index 8e71131..ef447d1 100644 (file)
@@ -254,11 +254,7 @@ class KafkaHandler extends AbstractProcessingHandler {
         * @param array $records List of records to append
         */
        protected function addMessages( $channel, array $records ) {
-               if ( isset( $this->options['alias'][$channel] ) ) {
-                       $topic = $this->options['alias'][$channel];
-               } else {
-                       $topic = "monolog_$channel";
-               }
+               $topic = $this->options['alias'][$channel] ?? "monolog_$channel";
                $partition = $this->getRandomPartition( $topic );
                if ( $partition !== null ) {
                        $this->produce->setMessages( $topic, $partition, $records );
index 716a092..03e479b 100644 (file)
@@ -66,8 +66,8 @@ class HTMLFormFieldWithButton extends HTMLFormField {
 
        /**
         * Combines the passed element with a button.
-        * @param String $element Element to combine the button with.
-        * @return String
+        * @param string $element Element to combine the button with.
+        * @return string
         */
        public function getElement( $element ) {
                return $element . "\u{00A0}" . $this->getInputHTML( '' );
index e9ecc40..477cc4c 100644 (file)
@@ -228,11 +228,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
        }
 
        public function getDefault() {
-               if ( isset( $this->mDefault ) ) {
-                       return $this->mDefault;
-               } else {
-                       return [];
-               }
+               return $this->mDefault ?? [];
        }
 
        public function filterDataForSubmit( $data ) {
index 257955c..435c34d 100644 (file)
@@ -97,11 +97,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
                $this->url = wfExpandUrl( $url, PROTO_HTTP );
                $this->parsedUrl = wfParseUrl( $this->url );
 
-               if ( isset( $options['logger'] ) ) {
-                       $this->logger = $options['logger'];
-               } else {
-                       $this->logger = new NullLogger();
-               }
+               $this->logger = $options['logger'] ?? new NullLogger();
 
                if ( !$this->parsedUrl || !Http::isValidURI( $this->url ) ) {
                        $this->status = StatusValue::newFatal( 'http-invalid-url', $url );
index 00a7b52..9098981 100644 (file)
@@ -914,11 +914,7 @@ class WikiImporter {
 
                        $revision->setText( $text );
                }
-               if ( isset( $revisionInfo['timestamp'] ) ) {
-                       $revision->setTimestamp( $revisionInfo['timestamp'] );
-               } else {
-                       $revision->setTimestamp( wfTimestampNow() );
-               }
+               $revision->setTimestamp( $revisionInfo['timestamp'] ?? wfTimestampNow() );
 
                if ( isset( $revisionInfo['comment'] ) ) {
                        $revision->setComment( $revisionInfo['comment'] );
index 0194822..f5d01d6 100644 (file)
@@ -164,10 +164,7 @@ abstract class DatabaseUpdater {
 
                // This will automatically add "AutoloadClasses" to $wgAutoloadClasses
                $data = $registry->readFromQueue( $queue );
-               $hooks = [];
-               if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
-                       $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
-               }
+               $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ?? [];
                if ( $vars && isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
                        $hooks = array_merge_recursive( $hooks, $vars['wgHooks']['LoadExtensionSchemaUpdates'] );
                }
index d51ea2e..029f67d 100644 (file)
@@ -537,11 +537,7 @@ abstract class Installer {
         * @return mixed
         */
        public function getVar( $name, $default = null ) {
-               if ( !isset( $this->settings[$name] ) ) {
-                       return $default;
-               } else {
-                       return $this->settings[$name];
-               }
+               return $this->settings[$name] ?? $default;
        }
 
        /**
@@ -1505,9 +1501,8 @@ abstract class Installer {
                $data = $registry->readFromQueue( $queue );
                $wgAutoloadClasses += $data['autoload'];
 
-               $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
-                       /** @suppress PhanUndeclaredVariable $wgHooks is set by DefaultSettings */
-                       $wgHooks['LoadExtensionSchemaUpdates'] : [];
+               /** @suppress PhanUndeclaredVariable $wgHooks is set by DefaultSettings */
+               $hooksWeWant = $wgHooks['LoadExtensionSchemaUpdates'] ?? [];
 
                if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
                        $hooksWeWant = array_merge_recursive(
index 1b0780b..e9a2d03 100644 (file)
@@ -192,11 +192,7 @@ class MysqlInstaller extends DatabaseInstaller {
                                        $existingSchema = false;
                                        $this->parent->showMessage( 'config-unknown-collation' );
                                }
-                               if ( isset( $row->Engine ) ) {
-                                       $existingEngine = $row->Engine;
-                               } else {
-                                       $existingEngine = $row->Type;
-                               }
+                               $existingEngine = $row->Engine ?? $row->Type;
                        }
                } else {
                        $existingSchema = false;
index d8281b0..f555c0f 100644 (file)
@@ -178,17 +178,9 @@ class WebInstaller extends Installer {
                        return $this->session;
                }
 
-               if ( isset( $session['happyPages'] ) ) {
-                       $this->happyPages = $session['happyPages'];
-               } else {
-                       $this->happyPages = [];
-               }
+               $this->happyPages = $session['happyPages'] ?? [];
 
-               if ( isset( $session['skippedPages'] ) ) {
-                       $this->skippedPages = $session['skippedPages'];
-               } else {
-                       $this->skippedPages = [];
-               }
+               $this->skippedPages = $session['skippedPages'] ?? [];
 
                $lowestUnhappy = $this->getLowestUnhappy();
 
@@ -468,11 +460,7 @@ class WebInstaller extends Installer {
         * @return array
         */
        public function getSession( $name, $default = null ) {
-               if ( !isset( $this->session[$name] ) ) {
-                       return $default;
-               } else {
-                       return $this->session[$name];
-               }
+               return $this->session[$name] ?? $default;
        }
 
        /**
@@ -932,11 +920,7 @@ class WebInstaller extends Installer {
                if ( !isset( $params['labelAttribs'] ) ) {
                        $params['labelAttribs'] = [];
                }
-               if ( isset( $params['rawtext'] ) ) {
-                       $labelText = $params['rawtext'];
-               } else {
-                       $labelText = $this->parse( wfMessage( $params['label'] )->text() );
-               }
+               $labelText = $params['rawtext'] ?? $this->parse( wfMessage( $params['label'] )->text() );
 
                return "<div class=\"config-input-check\">\n" .
                        $params['help'] .
@@ -978,11 +962,7 @@ class WebInstaller extends Installer {
        public function getRadioSet( $params ) {
                $items = $this->getRadioElements( $params );
 
-               if ( !isset( $params['label'] ) ) {
-                       $label = '';
-               } else {
-                       $label = $params['label'];
-               }
+               $label = $params['label'] ?? '';
 
                if ( !isset( $params['controlName'] ) ) {
                        $params['controlName'] = 'config_' . $params['var'];
index 0c7428f..f25d57c 100644 (file)
@@ -154,16 +154,8 @@ class WebInstallerExistingWiki extends WebInstallerPage {
                        return $status;
                }
 
-               if ( isset( $vars['wgDBadminuser'] ) ) {
-                       $this->setVar( '_InstallUser', $vars['wgDBadminuser'] );
-               } else {
-                       $this->setVar( '_InstallUser', $vars['wgDBuser'] );
-               }
-               if ( isset( $vars['wgDBadminpassword'] ) ) {
-                       $this->setVar( '_InstallPassword', $vars['wgDBadminpassword'] );
-               } else {
-                       $this->setVar( '_InstallPassword', $vars['wgDBpassword'] );
-               }
+               $this->setVar( '_InstallUser', $vars['wgDBadminuser'] ?? $vars['wgDBuser'] );
+               $this->setVar( '_InstallPassword', $vars['wgDBadminpassword'] ?? $vars['wgDBpassword'] );
 
                // Test the database connection
                $status = $installer->getConnection();
index 382ed3b..953295a 100644 (file)
@@ -490,11 +490,8 @@ class WebInstallerOptions extends WebInstallerPage {
                        // config-license-cc-0, config-license-pd, config-license-gfdl, config-license-none,
                        // config-license-cc-choose
                        $entry = $this->parent->licenses[$code];
-                       if ( isset( $entry['text'] ) ) {
-                               $this->setVar( 'wgRightsText', $entry['text'] );
-                       } else {
-                               $this->setVar( 'wgRightsText', wfMessage( 'config-license-' . $code )->text() );
-                       }
+                       $this->setVar( 'wgRightsText',
+                               $entry['text'] ?? wfMessage( 'config-license-' . $code )->text() );
                        $this->setVar( 'wgRightsUrl', $entry['url'] );
                        $this->setVar( 'wgRightsIcon', $entry['icon'] );
                } else {
index 820c492..c05feb4 100644 (file)
@@ -105,11 +105,7 @@ class JobQueueGroup {
                global $wgJobTypeConf;
 
                $conf = [ 'wiki' => $this->wiki, 'type' => $type ];
-               if ( isset( $wgJobTypeConf[$type] ) ) {
-                       $conf = $conf + $wgJobTypeConf[$type];
-               } else {
-                       $conf = $conf + $wgJobTypeConf['default'];
-               }
+               $conf += $wgJobTypeConf[$type] ?? $wgJobTypeConf['default'];
                $conf['aggregator'] = JobQueueAggregator::singleton();
                if ( !isset( $conf['readOnlyReason'] ) ) {
                        $conf['readOnlyReason'] = $this->readOnlyReason;
index 92a4f9e..3129c5b 100644 (file)
@@ -202,11 +202,7 @@ class CSSMin {
        public static function getMimeType( $file ) {
                // Infer the MIME-type from the file extension
                $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
-               if ( isset( self::$mimeTypes[$ext] ) ) {
-                       return self::$mimeTypes[$ext];
-               }
-
-               return mime_content_type( realpath( $file ) );
+               return self::$mimeTypes[$ext] ?? mime_content_type( realpath( $file ) );
        }
 
        /**
index c0ab0a0..b7636b1 100644 (file)
@@ -58,11 +58,7 @@ class Cookie {
                        $this->expires = strtotime( $attr['expires'] );
                }
 
-               if ( isset( $attr['path'] ) ) {
-                       $this->path = $attr['path'];
-               } else {
-                       $this->path = '/';
-               }
+               $this->path = $attr['path'] ?? '/';
 
                if ( isset( $attr['domain'] ) ) {
                        if ( self::validateCookieDomain( $attr['domain'] ) ) {
index a1bbd09..da0cae2 100644 (file)
@@ -46,6 +46,7 @@ class CryptRand {
         * @return string
         */
        protected function initialRandomState() {
+               wfDeprecated( __METHOD__, '1.32' );
                return '';
        }
 
@@ -59,6 +60,7 @@ class CryptRand {
         * @author Tim Starling
         */
        protected function driftHash( $data ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return '';
        }
 
@@ -70,6 +72,7 @@ class CryptRand {
         * @return string A new weak random state
         */
        protected function randomState() {
+               wfDeprecated( __METHOD__, '1.32' );
                return '';
        }
 
@@ -83,6 +86,7 @@ class CryptRand {
         * @return bool Always true
         */
        public function wasStrong() {
+               wfDeprecated( __METHOD__, '1.32' );
                return true;
        }
 
@@ -96,6 +100,7 @@ class CryptRand {
         * @return string Raw binary random data
         */
        public function generate( $bytes ) {
+               wfDeprecated( __METHOD__, '1.32' );
                $bytes = floor( $bytes );
                return random_bytes( $bytes );
        }
@@ -108,6 +113,7 @@ class CryptRand {
         * @return string Hexadecimal random data
         */
        public function generateHex( $chars ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return MWCryptRand::generateHex( $chars );
        }
 }
index 73f3e70..f67387b 100644 (file)
@@ -92,7 +92,7 @@ class JavaScriptMinifier {
         * Returns minified JavaScript code.
         *
         * @param string $s JavaScript code to minify
-        * @return String Minified code
+        * @return string Minified code
         */
        public static function minify( $s ) {
                // First we declare a few tables that contain our parsing rules
index 77c377b..b93084a 100644 (file)
@@ -753,11 +753,7 @@ EOT;
                $xml = new XmlTypeCheck( $file );
                if ( $xml->wellFormed ) {
                        $xmlTypes = $this->xmlTypes;
-                       if ( isset( $xmlTypes[$xml->getRootElement()] ) ) {
-                               return $xmlTypes[$xml->getRootElement()];
-                       } else {
-                               return 'application/xml';
-                       }
+                       return $xmlTypes[$xml->getRootElement()] ?? 'application/xml';
                }
 
                /**
index 82ae5ae..c6bcc7a 100644 (file)
@@ -112,11 +112,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
         * @param array $params
         */
        public function __construct( array $params = [] ) {
-               if ( isset( $params['logger'] ) ) {
-                       $this->setLogger( $params['logger'] );
-               } else {
-                       $this->setLogger( new NullLogger() );
-               }
+               $this->setLogger( $params['logger'] ?? new NullLogger() );
 
                if ( isset( $params['keyspace'] ) ) {
                        $this->keyspace = $params['keyspace'];
index a8047b0..a473210 100644 (file)
@@ -81,11 +81,7 @@ class RedisBagOStuff extends BagOStuff {
                        $this->serverTagMap[is_int( $key ) ? $server : $key] = $server;
                }
 
-               if ( isset( $params['automaticFailover'] ) ) {
-                       $this->automaticFailover = $params['automaticFailover'];
-               } else {
-                       $this->automaticFailover = true;
-               }
+               $this->automaticFailover = $params['automaticFailover'] ?? true;
 
                $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_NONE;
        }
index 61367f5..de102a7 100644 (file)
@@ -987,10 +987,7 @@ class DatabaseMssql extends Database {
         */
        public function getServerVersion() {
                $server_info = sqlsrv_server_info( $this->conn );
-               $version = 'Error';
-               if ( isset( $server_info['SQLServerVersion'] ) ) {
-                       $version = $server_info['SQLServerVersion'];
-               }
+               $version = $server_info['SQLServerVersion'] ?? 'Error';
 
                return $version;
        }
index 30074ec..cc6824d 100644 (file)
@@ -203,11 +203,7 @@ class LBFactoryMulti extends LBFactory {
                        return $this->lastSection;
                }
                list( $dbName, ) = $this->getDBNameAndPrefix( $domain );
-               if ( isset( $this->sectionsByDB[$dbName] ) ) {
-                       $section = $this->sectionsByDB[$dbName];
-               } else {
-                       $section = 'DEFAULT';
-               }
+               $section = $this->sectionsByDB[$dbName] ?? 'DEFAULT';
                $this->lastSection = $section;
                $this->lastDomain = $domain;
 
@@ -221,11 +217,7 @@ class LBFactoryMulti extends LBFactory {
        public function newMainLB( $domain = false ) {
                list( $dbName, ) = $this->getDBNameAndPrefix( $domain );
                $section = $this->getSectionForDomain( $domain );
-               if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
-                       $groupLoads = $this->groupLoadsByDB[$dbName];
-               } else {
-                       $groupLoads = [];
-               }
+               $groupLoads = $this->groupLoadsByDB[$dbName] ?? [];
 
                if ( isset( $this->groupLoadsBySection[$section] ) ) {
                        $groupLoads = array_merge_recursive(
@@ -370,11 +362,7 @@ class LBFactoryMulti extends LBFactory {
                        if ( isset( $groupLoadsByServer[$serverName] ) ) {
                                $serverInfo['groupLoads'] = $groupLoadsByServer[$serverName];
                        }
-                       if ( isset( $this->hostsByName[$serverName] ) ) {
-                               $serverInfo['host'] = $this->hostsByName[$serverName];
-                       } else {
-                               $serverInfo['host'] = $serverName;
-                       }
+                       $serverInfo['host'] = $this->hostsByName[$serverName] ?? $serverName;
                        $serverInfo['hostName'] = $serverName;
                        $serverInfo['load'] = $load;
                        $serverInfo += [ 'flags' => IDatabase::DBO_DEFAULT ];
index 1f3fe4c..ba40bda 100644 (file)
@@ -204,11 +204,7 @@ class LoadBalancer implements ILoadBalancer {
                        $this->maxLag = $params['maxLag'];
                }
 
-               if ( isset( $params['loadMonitor'] ) ) {
-                       $this->loadMonitorConfig = $params['loadMonitor'];
-               } else {
-                       $this->loadMonitorConfig = [ 'class' => 'LoadMonitorNull' ];
-               }
+               $this->loadMonitorConfig = $params['loadMonitor'] ?? [ 'class' => 'LoadMonitorNull' ];
                $this->loadMonitorConfig += [ 'lagWarnThreshold' => $this->maxLag ];
 
                foreach ( $params['servers'] as $i => $server ) {
@@ -223,22 +219,10 @@ class LoadBalancer implements ILoadBalancer {
                        }
                }
 
-               if ( isset( $params['srvCache'] ) ) {
-                       $this->srvCache = $params['srvCache'];
-               } else {
-                       $this->srvCache = new EmptyBagOStuff();
-               }
-               if ( isset( $params['wanCache'] ) ) {
-                       $this->wanCache = $params['wanCache'];
-               } else {
-                       $this->wanCache = WANObjectCache::newEmpty();
-               }
+               $this->srvCache = $params['srvCache'] ?? new EmptyBagOStuff();
+               $this->wanCache = $params['wanCache'] ?? WANObjectCache::newEmpty();
                $this->profiler = $params['profiler'] ?? null;
-               if ( isset( $params['trxProfiler'] ) ) {
-                       $this->trxProfiler = $params['trxProfiler'];
-               } else {
-                       $this->trxProfiler = new TransactionProfiler();
-               }
+               $this->trxProfiler = $params['trxProfiler'] ?? new TransactionProfiler();
 
                $this->errorLogger = $params['errorLogger'] ?? function ( Exception $e ) {
                        trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
@@ -1223,23 +1207,13 @@ class LoadBalancer implements ILoadBalancer {
        }
 
        public function getServerName( $i ) {
-               if ( isset( $this->servers[$i]['hostName'] ) ) {
-                       $name = $this->servers[$i]['hostName'];
-               } elseif ( isset( $this->servers[$i]['host'] ) ) {
-                       $name = $this->servers[$i]['host'];
-               } else {
-                       $name = '';
-               }
+               $name = $this->servers[$i]['hostName'] ?? $this->servers[$i]['host'] ?? '';
 
                return ( $name != '' ) ? $name : 'localhost';
        }
 
        public function getServerInfo( $i ) {
-               if ( isset( $this->servers[$i] ) ) {
-                       return $this->servers[$i];
-               } else {
-                       return false;
-               }
+               return $this->servers[$i] ?? false;
        }
 
        public function getServerType( $i ) {
index e14c485..b3afe0b 100644 (file)
@@ -51,13 +51,7 @@ class LogFormatter {
                global $wgLogActionsHandlers;
                $fulltype = $entry->getFullType();
                $wildcard = $entry->getType() . '/*';
-               $handler = '';
-
-               if ( isset( $wgLogActionsHandlers[$fulltype] ) ) {
-                       $handler = $wgLogActionsHandlers[$fulltype];
-               } elseif ( isset( $wgLogActionsHandlers[$wildcard] ) ) {
-                       $handler = $wgLogActionsHandlers[$wildcard];
-               }
+               $handler = $wgLogActionsHandlers[$fulltype] ?? $wgLogActionsHandlers[$wildcard] ?? '';
 
                if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
                        return new $handler( $entry );
index af99940..b63f818 100644 (file)
@@ -437,11 +437,7 @@ class LogPage {
                global $wgLogNames;
 
                // BC
-               if ( isset( $wgLogNames[$this->type] ) ) {
-                       $key = $wgLogNames[$this->type];
-               } else {
-                       $key = 'log-name-' . $this->type;
-               }
+               $key = $wgLogNames[$this->type] ?? 'log-name-' . $this->type;
 
                return wfMessage( $key );
        }
@@ -454,11 +450,7 @@ class LogPage {
        public function getDescription() {
                global $wgLogHeaders;
                // BC
-               if ( isset( $wgLogHeaders[$this->type] ) ) {
-                       $key = $wgLogHeaders[$this->type];
-               } else {
-                       $key = 'log-description-' . $this->type;
-               }
+               $key = $wgLogHeaders[$this->type] ?? 'log-description-' . $this->type;
 
                return wfMessage( $key );
        }
@@ -470,14 +462,8 @@ class LogPage {
         */
        public function getRestriction() {
                global $wgLogRestrictions;
-               if ( isset( $wgLogRestrictions[$this->type] ) ) {
-                       $restriction = $wgLogRestrictions[$this->type];
-               } else {
-                       // '' always returns true with $user->isAllowed()
-                       $restriction = '';
-               }
-
-               return $restriction;
+               // '' always returns true with $user->isAllowed()
+               return $wgLogRestrictions[$this->type] ?? '';
        }
 
        /**
index 441c515..683ded1 100644 (file)
@@ -222,11 +222,7 @@ class IPTC {
                                case '2#055':
                                        // Date created (not date digitized).
                                        // Maps to exif DateTimeOriginal
-                                       if ( isset( $parsed['2#060'] ) ) {
-                                               $time = $parsed['2#060'];
-                                       } else {
-                                               $time = [];
-                                       }
+                                       $time = $parsed['2#060'] ?? [];
                                        $timestamp = self::timeHelper( $val, $time, $c );
                                        if ( $timestamp ) {
                                                $data['DateTimeOriginal'] = $timestamp;
@@ -236,11 +232,7 @@ class IPTC {
                                case '2#062':
                                        // Date converted to digital representation.
                                        // Maps to exif DateTimeDigitized
-                                       if ( isset( $parsed['2#063'] ) ) {
-                                               $time = $parsed['2#063'];
-                                       } else {
-                                               $time = [];
-                                       }
+                                       $time = $parsed['2#063'] ?? [];
                                        $timestamp = self::timeHelper( $val, $time, $c );
                                        if ( $timestamp ) {
                                                $data['DateTimeDigitized'] = $timestamp;
@@ -249,11 +241,7 @@ class IPTC {
 
                                case '2#030':
                                        // Date released.
-                                       if ( isset( $parsed['2#035'] ) ) {
-                                               $time = $parsed['2#035'];
-                                       } else {
-                                               $time = [];
-                                       }
+                                       $time = $parsed['2#035'] ?? [];
                                        $timestamp = self::timeHelper( $val, $time, $c );
                                        if ( $timestamp ) {
                                                $data['DateTimeReleased'] = $timestamp;
@@ -262,11 +250,7 @@ class IPTC {
 
                                case '2#037':
                                        // Date expires.
-                                       if ( isset( $parsed['2#038'] ) ) {
-                                               $time = $parsed['2#038'];
-                                       } else {
-                                               $time = [];
-                                       }
+                                       $time = $parsed['2#038'] ?? [];
                                        $timestamp = self::timeHelper( $val, $time, $c );
                                        if ( $timestamp ) {
                                                $data['DateTimeExpires'] = $timestamp;
index 71db975..66a4291 100644 (file)
@@ -874,8 +874,8 @@ abstract class MediaHandler {
        /**
         * Converts a dimensions array about a potentially multipage document from an
         * exhaustive list of ordered page numbers to a list of page ranges
-        * @param Array $pagesByDimensions
-        * @return String
+        * @param array $pagesByDimensions
+        * @return string
         * @since 1.30
         */
        public static function getPageRangesByDimensions( $pagesByDimensions ) {
index 6d76d5e..ae42f80 100644 (file)
@@ -169,11 +169,7 @@ class ObjectCache {
         * @throws InvalidArgumentException
         */
        public static function newFromParams( $params ) {
-               if ( isset( $params['loggroup'] ) ) {
-                       $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] );
-               } else {
-                       $params['logger'] = LoggerFactory::getInstance( 'objectcache' );
-               }
+               $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' );
                if ( !isset( $params['keyspace'] ) ) {
                        $params['keyspace'] = self::getDefaultKeyspace();
                }
@@ -340,11 +336,7 @@ class ObjectCache {
                        }
                }
                $params['cache'] = self::newFromParams( $params['store'] );
-               if ( isset( $params['loggroup'] ) ) {
-                       $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] );
-               } else {
-                       $params['logger'] = LoggerFactory::getInstance( 'objectcache' );
-               }
+               $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' );
                if ( !$wgCommandLineMode ) {
                        // Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385)
                        $params['stats'] = $services->getStatsdDataFactory();
index de02861..fb79442 100644 (file)
@@ -213,10 +213,7 @@ class DateFormatter {
         */
        private function replace( $matches ) {
                # Extract information from $matches
-               $linked = true;
-               if ( isset( $this->mLinked ) ) {
-                       $linked = $this->mLinked;
-               }
+               $linked = $this->mLinked ?? true;
 
                $bits = [];
                $key = $this->keys[$this->mSource];
index 847214a..6260de6 100644 (file)
@@ -1127,11 +1127,7 @@ class ParserOutput extends CacheTime {
         *         or null if no value was set for this key.
         */
        public function getExtensionData( $key ) {
-               if ( isset( $this->mExtensionData[$key] ) ) {
-                       return $this->mExtensionData[$key];
-               }
-
-               return null;
+               return $this->mExtensionData[$key] ?? null;
        }
 
        private static function getTimes( $clock = null ) {
index d00c40f..f4e4efa 100644 (file)
@@ -1876,10 +1876,7 @@ class PPCustomFrame_DOM extends PPFrame_DOM {
         * @return string|bool
         */
        public function getArgument( $index ) {
-               if ( !isset( $this->args[$index] ) ) {
-                       return false;
-               }
-               return $this->args[$index];
+               return $this->args[$index] ?? false;
        }
 
        public function getArguments() {
index 6d6dd89..eb869e2 100644 (file)
@@ -1702,10 +1702,7 @@ class PPCustomFrame_Hash extends PPFrame_Hash {
         * @return string|bool
         */
        public function getArgument( $index ) {
-               if ( !isset( $this->args[$index] ) ) {
-                       return false;
-               }
-               return $this->args[$index];
+               return $this->args[$index] ?? false;
        }
 
        public function getArguments() {
index 3265ce7..ad45211 100644 (file)
@@ -267,11 +267,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
                                continue;
                        }
 
-                       if ( isset( $userGroupMemberships[$ueg] ) ) {
-                               $groupStringOrObject = $userGroupMemberships[$ueg];
-                       } else {
-                               $groupStringOrObject = $ueg;
-                       }
+                       $groupStringOrObject = $userGroupMemberships[$ueg] ?? $ueg;
 
                        $userG = UserGroupMembership::getLink( $groupStringOrObject, $context, 'html' );
                        $userM = UserGroupMembership::getLink( $groupStringOrObject, $context, 'html',
index eb56e13..e43b3b8 100644 (file)
@@ -484,11 +484,7 @@ class ExtensionProcessor implements Processor {
         * @param string $dir
         */
        protected function extractConfig2( array $info, $dir ) {
-               if ( isset( $info['config_prefix'] ) ) {
-                       $prefix = $info['config_prefix'];
-               } else {
-                       $prefix = 'wg';
-               }
+               $prefix = $info['config_prefix'] ?? 'wg';
                if ( isset( $info['config'] ) ) {
                        foreach ( $info['config'] as $key => $data ) {
                                $value = $data['value'];
index e2b60fc..2fc81e3 100644 (file)
@@ -550,11 +550,7 @@ class ResourceLoader implements LoggerAwareInterface {
                                $object->setConfig( $this->getConfig() );
                                $object->setLogger( $this->logger );
                        } else {
-                               if ( !isset( $info['class'] ) ) {
-                                       $class = ResourceLoaderFileModule::class;
-                               } else {
-                                       $class = $info['class'];
-                               }
+                               $class = $info['class'] ?? ResourceLoaderFileModule::class;
                                /** @var ResourceLoaderModule $object */
                                $object = new $class( $info );
                                $object->setConfig( $this->getConfig() );
@@ -1364,7 +1360,7 @@ MESSAGE;
         * - new XmlJsCode( '{}' )
         * - new stdClass() // (object) []
         *
-        * @param Array $array
+        * @param array $array
         */
        private static function trimArray( array &$array ) {
                $i = count( $array );
index ad9f934..2941f0a 100644 (file)
@@ -219,10 +219,7 @@ abstract class SearchEngine {
         * @return mixed the feature value or null if unset
         */
        public function getFeatureData( $feature ) {
-               if ( isset( $this->features[$feature] ) ) {
-                       return $this->features[$feature];
-               }
-               return null;
+               return $this->features[$feature] ?? null;
        }
 
        /**
index 0ddc443..467e4ef 100644 (file)
@@ -237,7 +237,7 @@ class Shell {
                // Give site config file a chance to run the script in a wrapper.
                // The caller may likely want to call wfBasename() on $script.
                Hooks::run( 'wfShellWikiCmd', [ &$script, &$parameters, &$options ] );
-               $cmd = isset( $options['php'] ) ? [ $options['php'] ] : [ $wgPhpCli ];
+               $cmd = [ $options['php'] ?? $wgPhpCli ];
                if ( isset( $options['wrapper'] ) ) {
                        $cmd[] = $options['wrapper'];
                }
index 6d98e72..f0a6e54 100644 (file)
@@ -87,11 +87,7 @@ class HashSiteStore implements SiteStore {
         * @return Site|null
         */
        public function getSite( $globalId, $source = 'cache' ) {
-               if ( isset( $this->sites[$globalId] ) ) {
-                       return $this->sites[$globalId];
-               } else {
-                       return null;
-               }
+               return $this->sites[$globalId] ?? null;
        }
 
        /**
index 64145ad..a71daa0 100644 (file)
@@ -371,11 +371,7 @@ abstract class BaseTemplate extends QuickTemplate {
         * @return string
         */
        function makeLink( $key, $item, $options = [] ) {
-               if ( isset( $item['text'] ) ) {
-                       $text = $item['text'];
-               } else {
-                       $text = wfMessage( $item['msg'] ?? $key )->text();
-               }
+               $text = $item['text'] ?? wfMessage( $item['msg'] ?? $key )->text();
 
                $html = htmlspecialchars( $text );
 
index 1889167..2c71571 100644 (file)
@@ -342,10 +342,7 @@ abstract class Skin extends ContextSource {
         * @return Title
         */
        public function getRelevantTitle() {
-               if ( isset( $this->mRelevantTitle ) ) {
-                       return $this->mRelevantTitle;
-               }
-               return $this->getTitle();
+               return $this->mRelevantTitle ?? $this->getTitle();
        }
 
        /**
index 887b13a..4201f80 100644 (file)
@@ -836,7 +836,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
        /**
         * Fetch the change tags list for the front end
         *
-        * @return Array Tag data
+        * @return array Tag data
         */
        protected function getChangeTagList() {
                $cache = ObjectCache::getMainWANInstance();
index b91273a..58212dd 100644 (file)
@@ -352,17 +352,11 @@ class SpecialPageFactory {
                $caseFoldedAlias = $this->contLang->caseFold( $bits[0] );
                $caseFoldedAlias = str_replace( ' ', '_', $caseFoldedAlias );
                $aliases = $this->getAliasList();
-               if ( isset( $aliases[$caseFoldedAlias] ) ) {
-                       $name = $aliases[$caseFoldedAlias];
-               } else {
+               if ( !isset( $aliases[$caseFoldedAlias] ) ) {
                        return [ null, null ];
                }
-
-               if ( !isset( $bits[1] ) ) { // T4087
-                       $par = null;
-               } else {
-                       $par = $bits[1];
-               }
+               $name = $aliases[$caseFoldedAlias];
+               $par = $bits[1] ?? null; // T4087
 
                return [ $name, $par ];
        }
@@ -504,11 +498,7 @@ class SpecialPageFactory {
                // @todo FIXME: Redirects broken due to this call
                $bits = explode( '/', $title->getDBkey(), 2 );
                $name = $bits[0];
-               if ( !isset( $bits[1] ) ) { // T4087
-                       $par = null;
-               } else {
-                       $par = $bits[1];
-               }
+               $par = $bits[1] ?? null; // T4087
 
                $page = $this->getPage( $name );
                if ( !$page ) {
index 809a14a..22a7612 100644 (file)
@@ -71,7 +71,7 @@ class SpecialGoToInterwiki extends UnlistedSpecialPage {
        }
 
        /**
-        * @return String
+        * @return string
         */
        protected function getGroupName() {
                return 'redirects';
index b6812bc..e591da0 100644 (file)
@@ -102,7 +102,7 @@ class MediaStatisticsPage extends QueryPage {
         *
         * It's important that img_media_type come first, otherwise the
         * tables will be fragmented.
-        * @return Array Fields to sort by
+        * @return array Fields to sort by
         */
        function getOrderFields() {
                return [ 'img_media_type', 'count(*)', 'img_major_mime', 'img_minor_mime' ];
@@ -214,7 +214,7 @@ class MediaStatisticsPage extends QueryPage {
 
        /**
         * @param float $decimal A decimal percentage (ie for 12.3%, this would be 0.123)
-        * @return String The percentage formatted so that 3 significant digits are shown.
+        * @return string The percentage formatted so that 3 significant digits are shown.
         */
        protected function makePercentPretty( $decimal ) {
                $decimal *= 100;
@@ -275,7 +275,7 @@ class MediaStatisticsPage extends QueryPage {
        /**
         * Get (not output) the header row for the table
         *
-        * @return String the header row of the able
+        * @return string The header row of the table
         */
        protected function getTableHeaderRow() {
                $headers = [ 'mimetype', 'extensions', 'count', 'totalbytes' ];
index f63c884..c82a943 100644 (file)
@@ -767,7 +767,7 @@ class UserrightsPage extends SpecialPage {
         * @param UserGroupMembership[] $usergroups Associative array of (group name as string =>
         *   UserGroupMembership object) for groups the user belongs to
         * @param User $user
-        * @return Array with 2 elements: the XHTML table element with checkxboes, and
+        * @return array Array with 2 elements: the XHTML table element with checkxboes, and
         * whether any groups are changeable
         */
        private function groupCheckboxes( $usergroups, $user ) {
index 6dc129c..f53ccea 100644 (file)
@@ -32,13 +32,10 @@ class UploadSourceField extends HTMLTextField {
                $label = Html::rawElement( 'label', [ 'for' => $id ], $this->mLabel );
 
                if ( !empty( $this->mParams['radio'] ) ) {
-                       if ( isset( $this->mParams['radio-id'] ) ) {
-                               $radioId = $this->mParams['radio-id'];
-                       } else {
+                       $radioId = $this->mParams['radio-id'] ??
                                // Old way. For the benefit of extensions that do not define
                                // the 'radio-id' key.
-                               $radioId = 'wpSourceType' . $this->mParams['upload-type'];
-                       }
+                               'wpSourceType' . $this->mParams['upload-type'];
 
                        $attribs = [
                                'name' => 'wpSourceType',
index dcebb60..ea805fb 100644 (file)
@@ -98,11 +98,7 @@ abstract class UploadBase {
                        self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename',
                        self::FILENAME_TOO_LONG => 'filename-toolong',
                ];
-               if ( isset( $code_to_status[$error] ) ) {
-                       return $code_to_status[$error];
-               }
-
-               return 'unknown-error';
+               return $code_to_status[$error] ?? 'unknown-error';
        }
 
        /**
index 48d54ec..9b08737 100644 (file)
@@ -1817,11 +1817,7 @@ class User implements IDBAccessObject, UserIdentity {
         */
        public static function getDefaultOption( $opt ) {
                $defOpts = self::getDefaultOptions();
-               if ( isset( $defOpts[$opt] ) ) {
-                       return $defOpts[$opt];
-               } else {
-                       return null;
-               }
+               return $defOpts[$opt] ?? null;
        }
 
        /**
index 0fc45f7..ec8bf5c 100644 (file)
@@ -32,6 +32,7 @@ class MWCryptRand {
         * @return CryptRand
         */
        protected static function singleton() {
+               wfDeprecated( __METHOD__, '1.32' );
                return MediaWikiServices::getInstance()->getCryptRand();
        }
 
@@ -45,6 +46,7 @@ class MWCryptRand {
         * @return bool Always true
         */
        public static function wasStrong() {
+               wfDeprecated( __METHOD__, '1.32' );
                return true;
        }
 
@@ -58,6 +60,7 @@ class MWCryptRand {
         * @return string Raw binary random data
         */
        public static function generate( $bytes ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return random_bytes( floor( $bytes ) );
        }
 
index a20435e..19a3ce5 100644 (file)
@@ -104,11 +104,7 @@ class MWFileProps {
                # NOTE: $gis[2] contains a code for the image type. This is no longer used.
                $info['width'] = $gis[0];
                $info['height'] = $gis[1];
-               if ( isset( $gis['bits'] ) ) {
-                       $info['bits'] = $gis['bits'];
-               } else {
-                       $info['bits'] = 0;
-               }
+               $info['bits'] = $gis['bits'] ?? 0;
 
                return $info;
        }
index 79380de..853601e 100644 (file)
@@ -128,11 +128,8 @@ class InterwikiSearchResultSetWidget implements SearchResultSetWidget {
                $interwiki = $this->iwLookup->fetch( $iwPrefix );
                $parsed = wfParseUrl( wfExpandUrl( $interwiki ? $interwiki->getURL() : '/' ) );
 
-               if ( isset( $this->customCaptions[$iwPrefix] ) ) {
-                       $caption = $this->customCaptions[$iwPrefix];
-               } else {
-                       $caption = $this->specialSearch->msg( 'search-interwiki-default', $parsed['host'] )->escaped();
-               }
+               $caption = $this->customCaptions[$iwPrefix] ??
+                       $this->specialSearch->msg( 'search-interwiki-default', $parsed['host'] )->escaped();
 
                $searchLink = Html::rawElement( 'em', null,
                        Html::rawElement( 'a', [ 'href' => $href, 'target' => '_blank' ], $caption )
index dc61519..999d648 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * Parser for rules of language conversion , parse rules in -{ }- tag.
+ * Parser for rules of language conversion, parse rules in -{ }- tag.
  * @ingroup Language
  * @author fdcn <fdcn64@gmail.com>, PhiLiP <philip.npc@gmail.com>
  */
@@ -29,13 +29,13 @@ class ConverterRule {
        public $mConverter; // LanguageConverter object
        public $mRuleDisplay = '';
        public $mRuleTitle = false;
-       public $mRules = '';// string : the text of the rules
+       public $mRules = ''; // string : the text of the rules
        public $mRulesAction = 'none';
        public $mFlags = [];
        public $mVariantFlags = [];
        public $mConvTable = [];
-       public $mBidtable = [];// array of the translation in each variant
-       public $mUnidtable = [];// array of the translation in each variant
+       public $mBidtable = []; // array of the translation in each variant
+       public $mUnidtable = []; // array of the translation in each variant
 
        /**
         * @param string $text The text between -{ and }-
index c838fc3..ab9a472 100644 (file)
@@ -11,6 +11,7 @@ use MediaWiki\Services\ServiceDisabledException;
  * @group MediaWiki
  */
 class MediaWikiServicesTest extends MediaWikiTestCase {
+       private $deprecatedServices = [ 'CryptRand' ];
 
        /**
         * @return Config
@@ -276,6 +277,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
                        $getterCases[$name] = [
                                'get' . $service,
                                $class,
+                               in_array( $service, $this->deprecatedServices )
                        ];
                }
 
@@ -285,7 +287,11 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideGetters
         */
-       public function testGetters( $getter, $type ) {
+       public function testGetters( $getter, $type, $isDeprecated = false ) {
+               if ( $isDeprecated ) {
+                       $this->hideDeprecated( MediaWikiServices::class . "::$getter" );
+               }
+
                // Test against the default instance, since the dummy will not know the default services.
                $services = MediaWikiServices::getInstance();
                $service = $services->$getter();
index 6b32c95..90413c4 100644 (file)
@@ -1442,10 +1442,13 @@ class OutputPageTest extends MediaWikiTestCase {
                $op = $this->newInstance();
                $this->assertSame( '', $op->getHTML() );
 
+               $this->hideDeprecated( 'OutputPage::addWikiText' );
                $this->hideDeprecated( 'OutputPage::addWikiTextTitle' );
                $this->hideDeprecated( 'OutputPage::addWikiTextWithTitle' );
                $this->hideDeprecated( 'OutputPage::addWikiTextTidy' );
                $this->hideDeprecated( 'OutputPage::addWikiTextTitleTidy' );
+               $this->hideDeprecated( 'disabling tidy' );
+
                if ( in_array(
                        $method,
                        [ 'addWikiTextWithTitle', 'addWikiTextTitleTidy', 'addWikiTextTitle' ]
@@ -1614,6 +1617,7 @@ class OutputPageTest extends MediaWikiTestCase {
         * @covers OutputPage::addWikiText
         */
        public function testAddWikiTextNoTitle() {
+               $this->hideDeprecated( 'OutputPage::addWikiText' );
                $this->setExpectedException( MWException::class, 'Title is null' );
 
                $op = $this->newInstance( [], null, 'notitle' );