From d1cf48a397edbbe9c6a63d6f83861d676f686d07 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 22 Jul 2017 18:24:09 -0700 Subject: [PATCH] build: Update mediawiki/mediawiki-codesniffer to 0.10.1 And auto-fix all errors. The `` stanzas are now included in the default ruleset and don't need to be repeated. Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a --- composer.json | 2 +- includes/Block.php | 28 +- includes/EditPage.php | 2 +- includes/LinkFilter.php | 2 +- includes/Linker.php | 8 +- includes/MWNamespace.php | 4 +- includes/MagicWord.php | 2 +- includes/MimeMagic.php | 2 +- includes/Preferences.php | 2 +- includes/Revision.php | 6 +- includes/Sanitizer.php | 66 ++--- includes/ServiceWiring.php | 4 +- includes/Setup.php | 2 +- includes/Title.php | 46 ++-- includes/WikiMap.php | 4 +- includes/Xml.php | 62 ++--- includes/actions/Action.php | 4 +- includes/api/ApiBase.php | 86 +++--- includes/api/ApiMain.php | 2 +- includes/api/ApiPageSet.php | 4 +- includes/api/ApiQueryImageInfo.php | 2 +- includes/api/ApiQueryInfo.php | 56 ++-- includes/api/ApiResult.php | 42 +-- includes/auth/AuthenticationResponse.php | 12 +- includes/cache/MessageCache.php | 2 +- includes/changes/RecentChange.php | 4 +- includes/collation/IcuCollation.php | 2 +- includes/content/ContentHandler.php | 16 +- includes/debug/MWDebug.php | 4 +- includes/export/WikiExporter.php | 28 +- includes/filerepo/ForeignAPIRepo.php | 2 +- includes/htmlform/HTMLForm.php | 2 +- includes/http/Http.php | 4 +- includes/import/ImportStreamSource.php | 4 +- includes/jobqueue/JobQueue.php | 2 +- includes/libs/CSSMin.php | 4 +- includes/libs/IP.php | 8 +- includes/libs/StringUtils.php | 4 +- includes/logging/LogPage.php | 4 +- includes/mail/UserMailer.php | 6 +- includes/media/Exif.php | 254 +++++++++--------- includes/page/WikiPage.php | 2 +- includes/pager/IndexPager.php | 2 +- includes/parser/Parser.php | 4 +- includes/parser/ParserOutput.php | 4 +- includes/resourceloader/ResourceLoader.php | 26 +- includes/skins/Skin.php | 2 +- includes/specialpage/SpecialPage.php | 2 +- includes/tidy/Balancer.php | 2 +- includes/user/BotPassword.php | 2 +- includes/user/User.php | 24 +- languages/Language.php | 58 ++-- maintenance/Maintenance.php | 4 +- maintenance/sqlite.inc | 2 +- maintenance/userOptions.inc | 2 +- phpcs.xml | 3 - tests/parser/ParserTestRunner.php | 2 +- .../phpunit/includes/DeprecatedGlobalTest.php | 2 +- tests/phpunit/includes/PreferencesTest.php | 3 +- .../includes/content/WikitextContentTest.php | 24 +- tests/phpunit/includes/page/WikiPageTest.php | 18 +- tests/phpunit/includes/site/TestSites.php | 2 +- 62 files changed, 493 insertions(+), 497 deletions(-) diff --git a/composer.json b/composer.json index 83fcda0cd5..d04e9f5c52 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "jetbrains/phpstorm-stubs": "dev-master#1b9906084d6635456fcf3f3a01f0d7d5b99a578a", "justinrainbow/json-schema": "~5.2", - "mediawiki/mediawiki-codesniffer": "0.8.1", + "mediawiki/mediawiki-codesniffer": "0.10.1", "monolog/monolog": "~1.22.1", "nikic/php-parser": "2.1.0", "nmred/kafka-php": "0.1.5", diff --git a/includes/Block.php b/includes/Block.php index 2c935df8ec..2a04879848 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -485,7 +485,7 @@ class Block { # Periodic purge via commit hooks if ( mt_rand( 0, 9 ) == 0 ) { - Block::purgeExpired(); + self::purgeExpired(); } $row = $this->getDatabaseArray(); @@ -778,12 +778,12 @@ class Block { # It's okay to autoblock. Go ahead and insert/update the block... # Do not add a *new* block if the IP is already blocked. - $ipblock = Block::newFromTarget( $autoblockIP ); + $ipblock = self::newFromTarget( $autoblockIP ); if ( $ipblock ) { # Check if the block is an autoblock and would exceed the user block # if renewed. If so, do nothing, otherwise prolong the block time... if ( $ipblock->mAuto && // @todo Why not compare $ipblock->mExpiry? - $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) + $this->mExpiry > self::getAutoblockExpiry( $ipblock->mTimestamp ) ) { # Reset block timestamp to now and its expiry to # $wgAutoblockExpiry in the future @@ -810,11 +810,11 @@ class Block { if ( $this->mExpiry == 'infinity' ) { # Original block was indefinite, start an autoblock now - $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp ); + $autoblock->mExpiry = self::getAutoblockExpiry( $timestamp ); } else { # If the user is already blocked with an expiry date, we don't # want to pile on top of that. - $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $timestamp ) ); + $autoblock->mExpiry = min( $this->mExpiry, self::getAutoblockExpiry( $timestamp ) ); } # Insert the block... @@ -870,7 +870,7 @@ class Block { public function updateTimestamp() { if ( $this->mAuto ) { $this->mTimestamp = wfTimestamp(); - $this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp ); + $this->mExpiry = self::getAutoblockExpiry( $this->mTimestamp ); $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'ipblocks', @@ -1111,8 +1111,8 @@ class Block { */ public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) { list( $target, $type ) = self::parseTarget( $specificTarget ); - if ( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) { - return Block::newFromID( $target ); + if ( $type == self::TYPE_ID || $type == self::TYPE_AUTO ) { + return self::newFromID( $target ); } elseif ( $target === null && $vagueTarget == '' ) { # We're not going to find anything useful here @@ -1122,7 +1122,7 @@ class Block { } elseif ( in_array( $type, - [ Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ] ) + [ self::TYPE_USER, self::TYPE_IP, self::TYPE_RANGE, null ] ) ) { $block = new Block(); $block->fromMaster( $fromMaster ); @@ -1189,7 +1189,7 @@ class Block { } $selectFields = array_merge( [ 'ipb_range_start', 'ipb_range_end' ], - Block::selectFields() + self::selectFields() ); $rows = $db->select( 'ipblocks', $selectFields, @@ -1350,12 +1350,12 @@ class Block { # off validation checking (which would exclude IP addresses) return [ User::newFromName( IP::sanitizeIP( $target ), false ), - Block::TYPE_IP + self::TYPE_IP ]; } elseif ( IP::isValidBlock( $target ) ) { # Can't create a User from an IP range - return [ IP::sanitizeRange( $target ), Block::TYPE_RANGE ]; + return [ IP::sanitizeRange( $target ), self::TYPE_RANGE ]; } # Consider the possibility that this is not a username at all @@ -1370,11 +1370,11 @@ class Block { # Note that since numbers are valid usernames, a $target of "12345" will be # considered a User. If you want to pass a block ID, prepend a hash "#12345", # since hash characters are not valid in usernames or titles generally. - return [ $userObj, Block::TYPE_USER ]; + return [ $userObj, self::TYPE_USER ]; } elseif ( preg_match( '/^#\d+$/', $target ) ) { # Autoblock reference in the form "#12345" - return [ substr( $target, 1 ), Block::TYPE_AUTO ]; + return [ substr( $target, 1 ), self::TYPE_AUTO ]; } else { # WTF? diff --git a/includes/EditPage.php b/includes/EditPage.php index 973327b0be..e3b7a10b7b 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2783,7 +2783,7 @@ class EditPage { $wgOut->addHTML( $this->editFormTextBeforeContent ); if ( !$this->isCssJsSubpage && $showToolbar && $wgUser->getOption( 'showtoolbar' ) ) { - $wgOut->addHTML( EditPage::getEditToolbar( $this->mTitle ) ); + $wgOut->addHTML( self::getEditToolbar( $this->mTitle ) ); } if ( $this->blankArticle ) { diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index 2f5055871a..790e2be448 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -50,7 +50,7 @@ class LinkFilter { $text = $content->getNativeData(); - $regex = LinkFilter::makeRegex( $filterEntry ); + $regex = self::makeRegex( $filterEntry ); return preg_match( $regex, $text ); } diff --git a/includes/Linker.php b/includes/Linker.php index f2e4ac4581..4aae3ba628 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1328,7 +1328,7 @@ class Linker { Title $title, $text, $wikiId = null, $options = [] ) { if ( $wikiId !== null && !$title->isExternal() ) { - $link = Linker::makeExternalLink( + $link = self::makeExternalLink( WikiMap::getForeignURL( $wikiId, $title->getNamespace() === 0 @@ -1341,7 +1341,7 @@ class Linker { /* escape = */ false // Already escaped ); } else { - $link = Linker::link( $title, $text, [], [], $options ); + $link = self::link( $title, $text, [], [], $options ); } return $link; @@ -2021,7 +2021,7 @@ class Linker { } if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) { - return Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops + return self::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops } else { if ( $rev->getId() ) { // RevDelete links using revision ID are stable across @@ -2040,7 +2040,7 @@ class Linker { 'ids' => $rev->getTimestamp() ]; } - return Linker::revDeleteLink( $query, + return self::revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide ); } } diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index 89cb616a7b..97dba26b95 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -370,7 +370,7 @@ class MWNamespace { */ public static function getSubjectNamespaces() { return array_filter( - MWNamespace::getValidNamespaces(), + self::getValidNamespaces(), 'MWNamespace::isSubject' ); } @@ -383,7 +383,7 @@ class MWNamespace { */ public static function getTalkNamespaces() { return array_filter( - MWNamespace::getValidNamespaces(), + self::getValidNamespaces(), 'MWNamespace::isTalk' ); } diff --git a/includes/MagicWord.php b/includes/MagicWord.php index ee95918700..1703179c9e 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -664,7 +664,7 @@ class MagicWord { $search = []; $replace = []; foreach ( $magicarr as $id => $replacement ) { - $mw = MagicWord::get( $id ); + $mw = self::get( $id ); $search[] = $mw->getRegex(); $replace[] = $replacement; } diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 8670729300..a2a44bb868 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -35,7 +35,7 @@ class MimeMagic extends MimeAnalyzer { $instance = MediaWikiServices::getInstance()->getMimeAnalyzer(); Assert::postcondition( $instance instanceof MimeMagic, - __METHOD__ . ' should return an instance of ' . MimeMagic::class + __METHOD__ . ' should return an instance of ' . self::class ); return $instance; } diff --git a/includes/Preferences.php b/includes/Preferences.php index 008963b5a7..7efbef1176 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1316,7 +1316,7 @@ class Preferences { $formClass = 'PreferencesForm', array $remove = [] ) { - $formDescriptor = Preferences::getPreferences( $user, $context ); + $formDescriptor = self::getPreferences( $user, $context ); if ( count( $remove ) ) { $removeKeys = array_flip( $remove ); $formDescriptor = array_diff_key( $formDescriptor, $removeKeys ); diff --git a/includes/Revision.php b/includes/Revision.php index c6b50f4651..537b7c11a6 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1002,7 +1002,7 @@ class Revision implements IDBAccessObject { return RecentChange::newFromConds( [ - 'rc_user_text' => $this->getUserText( Revision::RAW ), + 'rc_user_text' => $this->getUserText( self::RAW ), 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ), 'rc_this_oldid' => $this->getId() ], @@ -1466,7 +1466,7 @@ class Revision implements IDBAccessObject { ? $this->getPreviousRevisionId( $dbw ) : $this->mParentId, 'rev_sha1' => $this->mSha1 === null - ? Revision::base36Sha1( $this->mText ) + ? self::base36Sha1( $this->mText ) : $this->mSha1, ]; @@ -1555,7 +1555,7 @@ class Revision implements IDBAccessObject { } } - $content = $this->getContent( Revision::RAW ); + $content = $this->getContent( self::RAW ); $prefixedDBkey = $title->getPrefixedDBkey(); $revId = $this->mId; diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index b08bc69425..2def06a9dd 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -465,7 +465,7 @@ class Sanitizer { extract( self::getRecognizedTagData( $extratags, $removetags ) ); # Remove HTML comments - $text = Sanitizer::removeHTMLcomments( $text ); + $text = self::removeHTMLcomments( $text ); $bits = explode( '<', $text ); $text = str_replace( '>', '>', array_shift( $bits ) ); if ( !MWTidy::isEnabled() ) { @@ -583,12 +583,12 @@ class Sanitizer { call_user_func_array( $processCallback, [ &$params, $args ] ); } - if ( !Sanitizer::validateTag( $params, $t ) ) { + if ( !self::validateTag( $params, $t ) ) { $badtag = true; } # Strip non-approved attributes from the tag - $newparams = Sanitizer::fixTagAttributes( $params, $t ); + $newparams = self::fixTagAttributes( $params, $t ); } if ( !$badtag ) { $rest = str_replace( '>', '>', $rest ); @@ -629,11 +629,11 @@ class Sanitizer { call_user_func_array( $warnCallback, [ 'deprecated-self-close-category' ] ); } } - if ( !Sanitizer::validateTag( $params, $t ) ) { + if ( !self::validateTag( $params, $t ) ) { $badtag = true; } - $newparams = Sanitizer::fixTagAttributes( $params, $t ); + $newparams = self::fixTagAttributes( $params, $t ); if ( !$badtag ) { if ( $brace === '/>' && !isset( $htmlsingleonly[$t] ) ) { # Interpret self-closing tags as empty tags even when @@ -710,7 +710,7 @@ class Sanitizer { * @return bool */ static function validateTag( $params, $element ) { - $params = Sanitizer::decodeTagAttributes( $params ); + $params = self::decodeTagAttributes( $params ); if ( $element == 'meta' || $element == 'link' ) { if ( !isset( $params['itemprop'] ) ) { @@ -746,8 +746,8 @@ class Sanitizer { * @todo Check for unique id attribute :P */ static function validateTagAttributes( $attribs, $element ) { - return Sanitizer::validateAttributes( $attribs, - Sanitizer::attributeWhitelist( $element ) ); + return self::validateAttributes( $attribs, + self::attributeWhitelist( $element ) ); } /** @@ -795,12 +795,12 @@ class Sanitizer { # Strip javascript "expression" from stylesheets. # https://msdn.microsoft.com/en-us/library/ms537634.aspx if ( $attribute == 'style' ) { - $value = Sanitizer::checkCss( $value ); + $value = self::checkCss( $value ); } # Escape HTML id attributes if ( $attribute === 'id' ) { - $value = Sanitizer::escapeId( $value, 'noninitial' ); + $value = self::escapeId( $value, 'noninitial' ); } # Escape HTML id reference lists @@ -809,7 +809,7 @@ class Sanitizer { || $attribute === 'aria-labelledby' || $attribute === 'aria-owns' ) { - $value = Sanitizer::escapeIdReferenceList( $value, 'noninitial' ); + $value = self::escapeIdReferenceList( $value, 'noninitial' ); } // RDFa and microdata properties allow URLs, URIs and/or CURIs. @@ -907,7 +907,7 @@ class Sanitizer { */ public static function normalizeCss( $value ) { // Decode character references like { - $value = Sanitizer::decodeCharReferences( $value ); + $value = self::decodeCharReferences( $value ); // Decode escape sequences and line continuation // See the grammar in the CSS 2 spec, appendix D. @@ -1087,14 +1087,14 @@ class Sanitizer { return ''; } - $decoded = Sanitizer::decodeTagAttributes( $text ); - $stripped = Sanitizer::validateTagAttributes( $decoded, $element ); + $decoded = self::decodeTagAttributes( $text ); + $stripped = self::validateTagAttributes( $decoded, $element ); if ( $sorted ) { ksort( $stripped ); } - return Sanitizer::safeEncodeTagAttributes( $stripped ); + return self::safeEncodeTagAttributes( $stripped ); } /** @@ -1124,7 +1124,7 @@ class Sanitizer { * @return string HTML-encoded text fragment */ static function safeEncodeAttribute( $text ) { - $encValue = Sanitizer::encodeAttribute( $text ); + $encValue = self::encodeAttribute( $text ); # Templates and links may be expanded in later parsing, # creating invalid or dangerous output. Suppress this. @@ -1186,7 +1186,7 @@ class Sanitizer { global $wgExperimentalHtmlIds; $options = (array)$options; - $id = Sanitizer::decodeCharReferences( $id ); + $id = self::decodeCharReferences( $id ); if ( $wgExperimentalHtmlIds && !in_array( 'legacy', $options ) ) { $id = preg_replace( '/[ \t\n\r\f_\'"&#%]+/', '_', $id ); @@ -1238,7 +1238,7 @@ class Sanitizer { # Escape each token as an id foreach ( $references as &$ref ) { - $ref = Sanitizer::escapeId( $ref, $options ); + $ref = self::escapeId( $ref, $options ); } # Merge the array back to a space delimited list string @@ -1275,7 +1275,7 @@ class Sanitizer { * @return string Escaped input */ static function escapeHtmlAllowEntities( $html ) { - $html = Sanitizer::decodeCharReferences( $html ); + $html = self::decodeCharReferences( $html ); # It seems wise to escape ' as well as ", as a matter of course. Can't # hurt. Use ENT_SUBSTITUTE so that incorrectly truncated multibyte characters # don't cause the entire string to disappear. @@ -1317,14 +1317,14 @@ class Sanitizer { foreach ( $pairs as $set ) { $attribute = strtolower( $set[1] ); - $value = Sanitizer::getTagAttributeCallback( $set ); + $value = self::getTagAttributeCallback( $set ); // Normalize whitespace $value = preg_replace( '/[\t\r\n ]+/', ' ', $value ); $value = trim( $value ); // Decode character references - $attribs[$attribute] = Sanitizer::decodeCharReferences( $value ); + $attribs[$attribute] = self::decodeCharReferences( $value ); } return $attribs; } @@ -1340,7 +1340,7 @@ class Sanitizer { $attribs = []; foreach ( $assoc_array as $attribute => $value ) { $encAttribute = htmlspecialchars( $attribute ); - $encValue = Sanitizer::safeEncodeAttribute( $value ); + $encValue = self::safeEncodeAttribute( $value ); $attribs[] = "$encAttribute=\"$encValue\""; } @@ -1427,11 +1427,11 @@ class Sanitizer { static function normalizeCharReferencesCallback( $matches ) { $ret = null; if ( $matches[1] != '' ) { - $ret = Sanitizer::normalizeEntity( $matches[1] ); + $ret = self::normalizeEntity( $matches[1] ); } elseif ( $matches[2] != '' ) { - $ret = Sanitizer::decCharReference( $matches[2] ); + $ret = self::decCharReference( $matches[2] ); } elseif ( $matches[3] != '' ) { - $ret = Sanitizer::hexCharReference( $matches[3] ); + $ret = self::hexCharReference( $matches[3] ); } if ( is_null( $ret ) ) { return htmlspecialchars( $matches[0] ); @@ -1468,7 +1468,7 @@ class Sanitizer { */ static function decCharReference( $codepoint ) { $point = intval( $codepoint ); - if ( Sanitizer::validateCodepoint( $point ) ) { + if ( self::validateCodepoint( $point ) ) { return sprintf( '&#%d;', $point ); } else { return null; @@ -1481,7 +1481,7 @@ class Sanitizer { */ static function hexCharReference( $codepoint ) { $point = hexdec( $codepoint ); - if ( Sanitizer::validateCodepoint( $point ) ) { + if ( self::validateCodepoint( $point ) ) { return sprintf( '&#x%x;', $point ); } else { return null; @@ -1550,11 +1550,11 @@ class Sanitizer { */ static function decodeCharReferencesCallback( $matches ) { if ( $matches[1] != '' ) { - return Sanitizer::decodeEntity( $matches[1] ); + return self::decodeEntity( $matches[1] ); } elseif ( $matches[2] != '' ) { - return Sanitizer::decodeChar( intval( $matches[2] ) ); + return self::decodeChar( intval( $matches[2] ) ); } elseif ( $matches[3] != '' ) { - return Sanitizer::decodeChar( hexdec( $matches[3] ) ); + return self::decodeChar( hexdec( $matches[3] ) ); } # Last case should be an ampersand by itself return $matches[0]; @@ -1568,7 +1568,7 @@ class Sanitizer { * @private */ static function decodeChar( $codepoint ) { - if ( Sanitizer::validateCodepoint( $codepoint ) ) { + if ( self::validateCodepoint( $codepoint ) ) { return UtfNormal\Utils::codepointToUtf8( $codepoint ); } else { return UtfNormal\Constants::UTF8_REPLACEMENT; @@ -1601,7 +1601,7 @@ class Sanitizer { * @return array */ static function attributeWhitelist( $element ) { - $list = Sanitizer::setupAttributeWhitelist(); + $list = self::setupAttributeWhitelist(); return isset( $list[$element] ) ? $list[$element] : []; @@ -1876,7 +1876,7 @@ class Sanitizer { static function cleanUrl( $url ) { # Normalize any HTML entities in input. They will be # re-escaped by makeExternalLink(). - $url = Sanitizer::decodeCharReferences( $url ); + $url = self::decodeCharReferences( $url ); # Escape any control characters introduced by the above step $url = preg_replace_callback( '/[\][<>"\\x00-\\x20\\x7F\|]/', diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index e1244e7590..d048007c3a 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -287,7 +287,7 @@ return [ return ObjectFactory::constructClassInstance( $conf['class'], [ $conf ] ); }, - 'ParserCache' => function( MediaWikiServices $services ) { + 'ParserCache' => function ( MediaWikiServices $services ) { $config = $services->getMainConfig(); $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) ); wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) ); @@ -298,7 +298,7 @@ return [ ); }, - 'LinkCache' => function( MediaWikiServices $services ) { + 'LinkCache' => function ( MediaWikiServices $services ) { return new LinkCache( $services->getTitleFormatter(), $services->getMainWANObjectCache() diff --git a/includes/Setup.php b/includes/Setup.php index ac00fab741..3d5bee2a08 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -687,7 +687,7 @@ $messageMemc = wfGetMessageCacheStorage(); /** * @deprecated since 1.30 */ -$parserMemc = new DeprecatedGlobal( 'parserMemc', function() { +$parserMemc = new DeprecatedGlobal( 'parserMemc', function () { return MediaWikiServices::getInstance()->getParserCache()->getCacheStorage(); }, '1.30' ); diff --git a/includes/Title.php b/includes/Title.php index 083a725d98..6538538e8e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -272,7 +272,7 @@ class Title implements LinkTarget { } try { - return Title::newFromTextThrow( strval( $text ), $defaultNamespace ); + return self::newFromTextThrow( strval( $text ), $defaultNamespace ); } catch ( MalformedTitleException $ex ) { return null; } @@ -411,7 +411,7 @@ class Title implements LinkTarget { __METHOD__ ); if ( $row !== false ) { - $title = Title::newFromRow( $row ); + $title = self::newFromRow( $row ); } else { $title = null; } @@ -439,7 +439,7 @@ class Title implements LinkTarget { $titles = []; foreach ( $res as $row ) { - $titles[] = Title::newFromRow( $row ); + $titles[] = self::newFromRow( $row ); } return $titles; } @@ -541,7 +541,7 @@ class Title implements LinkTarget { } $t = new Title(); - $t->mDbkeyform = Title::makeName( $ns, $title, $fragment, $interwiki, true ); + $t->mDbkeyform = self::makeName( $ns, $title, $fragment, $interwiki, true ); try { $t->secureAndSplit(); @@ -557,10 +557,10 @@ class Title implements LinkTarget { * @return Title The new object */ public static function newMainPage() { - $title = Title::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() ); + $title = self::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() ); // Don't give fatal errors if the message is broken if ( !$title ) { - $title = Title::newFromText( 'Main Page' ); + $title = self::newFromText( 'Main Page' ); } return $title; } @@ -933,7 +933,7 @@ class Title implements LinkTarget { */ public function getContentModel( $flags = 0 ) { if ( !$this->mForcedContentModel - && ( !$this->mContentModel || $flags === Title::GAID_FOR_UPDATE ) + && ( !$this->mContentModel || $flags === self::GAID_FOR_UPDATE ) && $this->getArticleID( $flags ) ) { $linkCache = LinkCache::singleton(); @@ -1096,7 +1096,7 @@ class Title implements LinkTarget { if ( $canonicalName ) { $localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par ); if ( $localName != $this->mDbkeyform ) { - return Title::makeTitle( NS_SPECIAL, $localName ); + return self::makeTitle( NS_SPECIAL, $localName ); } } } @@ -1195,7 +1195,7 @@ class Title implements LinkTarget { * @return bool */ public function isMainPage() { - return $this->equals( Title::newMainPage() ); + return $this->equals( self::newMainPage() ); } /** @@ -1313,7 +1313,7 @@ class Title implements LinkTarget { * @return Title The object for the talk page */ public function getTalkPage() { - return Title::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() ); + return self::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() ); } /** @@ -1328,7 +1328,7 @@ class Title implements LinkTarget { if ( $this->getNamespace() == $subjectNS ) { return $this; } - return Title::makeTitle( $subjectNS, $this->getDBkey() ); + return self::makeTitle( $subjectNS, $this->getDBkey() ); } /** @@ -1388,7 +1388,7 @@ class Title implements LinkTarget { if ( !$this->hasFragment() ) { return ''; } else { - return '#' . Title::escapeFragmentForURL( $this->getFragment() ); + return '#' . self::escapeFragmentForURL( $this->getFragment() ); } } @@ -1535,7 +1535,7 @@ class Title implements LinkTarget { * @since 1.20 */ public function getRootTitle() { - return Title::makeTitle( $this->getNamespace(), $this->getRootText() ); + return self::makeTitle( $this->getNamespace(), $this->getRootText() ); } /** @@ -1575,7 +1575,7 @@ class Title implements LinkTarget { * @since 1.20 */ public function getBaseTitle() { - return Title::makeTitle( $this->getNamespace(), $this->getBaseText() ); + return self::makeTitle( $this->getNamespace(), $this->getBaseText() ); } /** @@ -1611,7 +1611,7 @@ class Title implements LinkTarget { * @since 1.20 */ public function getSubpage( $text ) { - return Title::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text ); + return self::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text ); } /** @@ -2847,7 +2847,7 @@ class Title implements LinkTarget { $page_id = $row->pr_page; $page_ns = $row->page_namespace; $page_title = $row->page_title; - $sources[$page_id] = Title::makeTitle( $page_ns, $page_title ); + $sources[$page_id] = self::makeTitle( $page_ns, $page_title ); # Add groups needed for each restriction type if its not already there # Make sure this restriction type still exists @@ -3329,7 +3329,7 @@ class Title implements LinkTarget { * @return int Int or 0 if the page doesn't exist */ public function getLatestRevID( $flags = 0 ) { - if ( !( $flags & Title::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) { + if ( !( $flags & self::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) { return intval( $this->mLatestID ); } if ( !$this->getArticleID( $flags ) ) { @@ -3489,7 +3489,7 @@ class Title implements LinkTarget { if ( $res->numRows() ) { $linkCache = LinkCache::singleton(); foreach ( $res as $row ) { - $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ); + $titleObj = self::makeTitle( $row->page_namespace, $row->page_title ); if ( $titleObj ) { $linkCache->addGoodLinkObjFromRow( $titleObj, $row ); $retVal[] = $titleObj; @@ -3557,9 +3557,9 @@ class Title implements LinkTarget { $linkCache = LinkCache::singleton(); foreach ( $res as $row ) { if ( $row->page_id ) { - $titleObj = Title::newFromRow( $row ); + $titleObj = self::newFromRow( $row ); } else { - $titleObj = Title::makeTitle( $row->$blNamespace, $row->$blTitle ); + $titleObj = self::makeTitle( $row->$blNamespace, $row->$blTitle ); $linkCache->addBadLinkObj( $titleObj ); } $retVal[] = $titleObj; @@ -3615,7 +3615,7 @@ class Title implements LinkTarget { $retVal = []; foreach ( $res as $row ) { - $retVal[] = Title::makeTitle( $row->pl_namespace, $row->pl_title ); + $retVal[] = self::makeTitle( $row->pl_namespace, $row->pl_title ); } return $retVal; } @@ -3827,7 +3827,7 @@ class Title implements LinkTarget { } # T16385: we need makeTitleSafe because the new page names may # be longer than 255 characters. - $newSubpage = Title::makeTitleSafe( $newNs, $newPageName ); + $newSubpage = self::makeTitleSafe( $newNs, $newPageName ); $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags ); if ( $success === true ) { @@ -3989,7 +3989,7 @@ class Title implements LinkTarget { # Circular reference $stack[$parent] = []; } else { - $nt = Title::newFromText( $parent ); + $nt = self::newFromText( $parent ); if ( $nt ) { $stack[$parent] = $nt->getParentCategoryTree( $children + [ $parent => 1 ] ); } diff --git a/includes/WikiMap.php b/includes/WikiMap.php index a03bc19412..6a532e5da5 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -115,7 +115,7 @@ class WikiMap { * @return string|int Wiki's name or $wiki_id if the wiki was not found */ public static function getWikiName( $wikiID ) { - $wiki = WikiMap::getWiki( $wikiID ); + $wiki = self::getWiki( $wikiID ); if ( $wiki ) { return $wiki->getDisplayName(); @@ -166,7 +166,7 @@ class WikiMap { * @return string|bool URL or false if the wiki was not found */ public static function getForeignURL( $wikiID, $page, $fragmentId = null ) { - $wiki = WikiMap::getWiki( $wikiID ); + $wiki = self::getWiki( $wikiID ); if ( $wiki ) { return $wiki->getFullUrl( $page, $fragmentId ); diff --git a/includes/Xml.php b/includes/Xml.php index d0164331e1..16a5a9ddec 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -225,7 +225,7 @@ class Xml { $selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode; $options = "\n"; foreach ( $languages as $code => $name ) { - $options .= Xml::option( "$code - $name", $code, $code == $selected ) . "\n"; + $options .= self::option( "$code - $name", $code, $code == $selected ) . "\n"; } $attrs = [ 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' ]; @@ -235,8 +235,8 @@ class Xml { $msg = wfMessage( 'yourlanguage' ); } return [ - Xml::label( $msg->text(), $attrs['id'] ), - Xml::tags( 'select', $attrs, $options ) + self::label( $msg->text(), $attrs['id'] ), + self::tags( 'select', $attrs, $options ) ]; } @@ -400,7 +400,7 @@ class Xml { $value = false, $attribs = [] ) { return [ - Xml::label( $label, $id, $attribs ), + self::label( $label, $id, $attribs ), self::input( $name, $size, $value, [ 'id' => $id ] + $attribs ) ]; } @@ -556,11 +556,11 @@ class Xml { $attribs['tabindex'] = $tabindex; } - return Xml::openElement( 'select', $attribs ) + return self::openElement( 'select', $attribs ) . "\n" . $options . "\n" - . Xml::closeElement( 'select' ); + . self::closeElement( 'select' ); } /** @@ -575,15 +575,15 @@ class Xml { * @return string */ public static function fieldset( $legend = false, $content = false, $attribs = [] ) { - $s = Xml::openElement( 'fieldset', $attribs ) . "\n"; + $s = self::openElement( 'fieldset', $attribs ) . "\n"; if ( $legend ) { - $s .= Xml::element( 'legend', null, $legend ) . "\n"; + $s .= self::element( 'legend', null, $legend ) . "\n"; } if ( $content !== false ) { $s .= $content . "\n"; - $s .= Xml::closeElement( 'fieldset' ) . "\n"; + $s .= self::closeElement( 'fieldset' ) . "\n"; } return $s; @@ -644,7 +644,7 @@ class Xml { */ public static function encodeJsCall( $name, $args, $pretty = false ) { foreach ( $args as &$arg ) { - $arg = Xml::encodeJsVar( $arg, $pretty ); + $arg = self::encodeJsVar( $arg, $pretty ); if ( $arg === false ) { return false; } @@ -702,7 +702,7 @@ class Xml { $text . ''; - return Xml::isWellFormed( $html ); + return self::isWellFormed( $html ); } /** @@ -736,25 +736,25 @@ class Xml { foreach ( $fields as $labelmsg => $input ) { $id = "mw-$labelmsg"; - $form .= Xml::openElement( 'tr', [ 'id' => $id ] ); + $form .= self::openElement( 'tr', [ 'id' => $id ] ); // TODO use a