And auto-fix all errors.
The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.
Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
"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",
# Periodic purge via commit hooks
if ( mt_rand( 0, 9 ) == 0 ) {
- Block::purgeExpired();
+ self::purgeExpired();
}
$row = $this->getDatabaseArray();
# 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
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...
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',
*/
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
} 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 );
}
$selectFields = array_merge(
[ 'ipb_range_start', 'ipb_range_end' ],
- Block::selectFields()
+ self::selectFields()
);
$rows = $db->select( 'ipblocks',
$selectFields,
# 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
# 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?
$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 ) {
$text = $content->getNativeData();
- $regex = LinkFilter::makeRegex( $filterEntry );
+ $regex = self::makeRegex( $filterEntry );
return preg_match( $regex, $text );
}
Title $title, $text, $wikiId = null, $options = []
) {
if ( $wikiId !== null && !$title->isExternal() ) {
- $link = Linker::makeExternalLink(
+ $link = self::makeExternalLink(
WikiMap::getForeignURL(
$wikiId,
$title->getNamespace() === 0
/* escape = */ false // Already escaped
);
} else {
- $link = Linker::link( $title, $text, [], [], $options );
+ $link = self::link( $title, $text, [], [], $options );
}
return $link;
}
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
'ids' => $rev->getTimestamp()
];
}
- return Linker::revDeleteLink( $query,
+ return self::revDeleteLink( $query,
$rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
}
}
*/
public static function getSubjectNamespaces() {
return array_filter(
- MWNamespace::getValidNamespaces(),
+ self::getValidNamespaces(),
'MWNamespace::isSubject'
);
}
*/
public static function getTalkNamespaces() {
return array_filter(
- MWNamespace::getValidNamespaces(),
+ self::getValidNamespaces(),
'MWNamespace::isTalk'
);
}
$search = [];
$replace = [];
foreach ( $magicarr as $id => $replacement ) {
- $mw = MagicWord::get( $id );
+ $mw = self::get( $id );
$search[] = $mw->getRegex();
$replace[] = $replacement;
}
$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;
}
$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 );
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()
],
? $this->getPreviousRevisionId( $dbw )
: $this->mParentId,
'rev_sha1' => $this->mSha1 === null
- ? Revision::base36Sha1( $this->mText )
+ ? self::base36Sha1( $this->mText )
: $this->mSha1,
];
}
}
- $content = $this->getContent( Revision::RAW );
+ $content = $this->getContent( self::RAW );
$prefixedDBkey = $title->getPrefixedDBkey();
$revId = $this->mId;
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() ) {
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 );
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
* @return bool
*/
static function validateTag( $params, $element ) {
- $params = Sanitizer::decodeTagAttributes( $params );
+ $params = self::decodeTagAttributes( $params );
if ( $element == 'meta' || $element == 'link' ) {
if ( !isset( $params['itemprop'] ) ) {
* @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 ) );
}
/**
# 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
|| $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.
*/
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.
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 );
}
/**
* @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.
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 );
# 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
* @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.
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;
}
$attribs = [];
foreach ( $assoc_array as $attribute => $value ) {
$encAttribute = htmlspecialchars( $attribute );
- $encValue = Sanitizer::safeEncodeAttribute( $value );
+ $encValue = self::safeEncodeAttribute( $value );
$attribs[] = "$encAttribute=\"$encValue\"";
}
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] );
*/
static function decCharReference( $codepoint ) {
$point = intval( $codepoint );
- if ( Sanitizer::validateCodepoint( $point ) ) {
+ if ( self::validateCodepoint( $point ) ) {
return sprintf( '&#%d;', $point );
} else {
return null;
*/
static function hexCharReference( $codepoint ) {
$point = hexdec( $codepoint );
- if ( Sanitizer::validateCodepoint( $point ) ) {
+ if ( self::validateCodepoint( $point ) ) {
return sprintf( '&#x%x;', $point );
} else {
return null;
*/
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];
* @private
*/
static function decodeChar( $codepoint ) {
- if ( Sanitizer::validateCodepoint( $codepoint ) ) {
+ if ( self::validateCodepoint( $codepoint ) ) {
return UtfNormal\Utils::codepointToUtf8( $codepoint );
} else {
return UtfNormal\Constants::UTF8_REPLACEMENT;
* @return array
*/
static function attributeWhitelist( $element ) {
- $list = Sanitizer::setupAttributeWhitelist();
+ $list = self::setupAttributeWhitelist();
return isset( $list[$element] )
? $list[$element]
: [];
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\|]/',
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 ) );
);
},
- 'LinkCache' => function( MediaWikiServices $services ) {
+ 'LinkCache' => function ( MediaWikiServices $services ) {
return new LinkCache(
$services->getTitleFormatter(),
$services->getMainWANObjectCache()
/**
* @deprecated since 1.30
*/
-$parserMemc = new DeprecatedGlobal( 'parserMemc', function() {
+$parserMemc = new DeprecatedGlobal( 'parserMemc', function () {
return MediaWikiServices::getInstance()->getParserCache()->getCacheStorage();
}, '1.30' );
}
try {
- return Title::newFromTextThrow( strval( $text ), $defaultNamespace );
+ return self::newFromTextThrow( strval( $text ), $defaultNamespace );
} catch ( MalformedTitleException $ex ) {
return null;
}
__METHOD__
);
if ( $row !== false ) {
- $title = Title::newFromRow( $row );
+ $title = self::newFromRow( $row );
} else {
$title = null;
}
$titles = [];
foreach ( $res as $row ) {
- $titles[] = Title::newFromRow( $row );
+ $titles[] = self::newFromRow( $row );
}
return $titles;
}
}
$t = new Title();
- $t->mDbkeyform = Title::makeName( $ns, $title, $fragment, $interwiki, true );
+ $t->mDbkeyform = self::makeName( $ns, $title, $fragment, $interwiki, true );
try {
$t->secureAndSplit();
* @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;
}
*/
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();
if ( $canonicalName ) {
$localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par );
if ( $localName != $this->mDbkeyform ) {
- return Title::makeTitle( NS_SPECIAL, $localName );
+ return self::makeTitle( NS_SPECIAL, $localName );
}
}
}
* @return bool
*/
public function isMainPage() {
- return $this->equals( Title::newMainPage() );
+ return $this->equals( self::newMainPage() );
}
/**
* @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() );
}
/**
if ( $this->getNamespace() == $subjectNS ) {
return $this;
}
- return Title::makeTitle( $subjectNS, $this->getDBkey() );
+ return self::makeTitle( $subjectNS, $this->getDBkey() );
}
/**
if ( !$this->hasFragment() ) {
return '';
} else {
- return '#' . Title::escapeFragmentForURL( $this->getFragment() );
+ return '#' . self::escapeFragmentForURL( $this->getFragment() );
}
}
* @since 1.20
*/
public function getRootTitle() {
- return Title::makeTitle( $this->getNamespace(), $this->getRootText() );
+ return self::makeTitle( $this->getNamespace(), $this->getRootText() );
}
/**
* @since 1.20
*/
public function getBaseTitle() {
- return Title::makeTitle( $this->getNamespace(), $this->getBaseText() );
+ return self::makeTitle( $this->getNamespace(), $this->getBaseText() );
}
/**
* @since 1.20
*/
public function getSubpage( $text ) {
- return Title::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text );
+ return self::makeTitleSafe( $this->getNamespace(), $this->getText() . '/' . $text );
}
/**
$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
* @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 ) ) {
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;
$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;
$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;
}
}
# 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 ) {
# Circular reference
$stack[$parent] = [];
} else {
- $nt = Title::newFromText( $parent );
+ $nt = self::newFromText( $parent );
if ( $nt ) {
$stack[$parent] = $nt->getParentCategoryTree( $children + [ $parent => 1 ] );
}
* @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();
* @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 );
$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' ];
$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 )
];
}
$value = false, $attribs = []
) {
return [
- Xml::label( $label, $id, $attribs ),
+ self::label( $label, $id, $attribs ),
self::input( $name, $size, $value, [ 'id' => $id ] + $attribs )
];
}
$attribs['tabindex'] = $tabindex;
}
- return Xml::openElement( 'select', $attribs )
+ return self::openElement( 'select', $attribs )
. "\n"
. $options
. "\n"
- . Xml::closeElement( 'select' );
+ . self::closeElement( 'select' );
}
/**
* @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;
*/
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;
}
$text .
'</html>';
- return Xml::isWellFormed( $html );
+ return self::isWellFormed( $html );
}
/**
foreach ( $fields as $labelmsg => $input ) {
$id = "mw-$labelmsg";
- $form .= Xml::openElement( 'tr', [ 'id' => $id ] );
+ $form .= self::openElement( 'tr', [ 'id' => $id ] );
// TODO use a <label> here for accessibility purposes - will need
// to either not use a table to build the form, or find the ID of
// the input somehow.
- $form .= Xml::tags( 'td', [ 'class' => 'mw-label' ], wfMessage( $labelmsg )->parse() );
- $form .= Xml::openElement( 'td', [ 'class' => 'mw-input' ] )
- . $input . Xml::closeElement( 'td' );
- $form .= Xml::closeElement( 'tr' );
+ $form .= self::tags( 'td', [ 'class' => 'mw-label' ], wfMessage( $labelmsg )->parse() );
+ $form .= self::openElement( 'td', [ 'class' => 'mw-input' ] )
+ . $input . self::closeElement( 'td' );
+ $form .= self::closeElement( 'tr' );
}
if ( $submitLabel ) {
- $form .= Xml::openElement( 'tr' );
- $form .= Xml::tags( 'td', [], '' );
- $form .= Xml::openElement( 'td', [ 'class' => 'mw-submit' ] )
- . Xml::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs )
- . Xml::closeElement( 'td' );
- $form .= Xml::closeElement( 'tr' );
+ $form .= self::openElement( 'tr' );
+ $form .= self::tags( 'td', [], '' );
+ $form .= self::openElement( 'td', [ 'class' => 'mw-submit' ] )
+ . self::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs )
+ . self::closeElement( 'td' );
+ $form .= self::closeElement( 'tr' );
}
$form .= "</tbody></table>";
* @return string
*/
public static function buildTable( $rows, $attribs = [], $headers = null ) {
- $s = Xml::openElement( 'table', $attribs );
+ $s = self::openElement( 'table', $attribs );
if ( is_array( $headers ) ) {
- $s .= Xml::openElement( 'thead', $attribs );
+ $s .= self::openElement( 'thead', $attribs );
foreach ( $headers as $id => $header ) {
$attribs = [];
$attribs['id'] = $id;
}
- $s .= Xml::element( 'th', $attribs, $header );
+ $s .= self::element( 'th', $attribs, $header );
}
- $s .= Xml::closeElement( 'thead' );
+ $s .= self::closeElement( 'thead' );
}
foreach ( $rows as $id => $row ) {
$attribs['id'] = $id;
}
- $s .= Xml::buildTableRow( $attribs, $row );
+ $s .= self::buildTableRow( $attribs, $row );
}
- $s .= Xml::closeElement( 'table' );
+ $s .= self::closeElement( 'table' );
return $s;
}
* @return string
*/
public static function buildTableRow( $attribs, $cells ) {
- $s = Xml::openElement( 'tr', $attribs );
+ $s = self::openElement( 'tr', $attribs );
foreach ( $cells as $id => $cell ) {
$attribs = [];
$attribs['id'] = $id;
}
- $s .= Xml::element( 'td', $attribs, $cell );
+ $s .= self::element( 'td', $attribs, $cell );
}
- $s .= Xml::closeElement( 'tr' );
+ $s .= self::closeElement( 'tr' );
return $s;
}
return 'view';
}
- $action = Action::factory( $actionName, $context->getWikiPage(), $context );
+ $action = self::factory( $actionName, $context->getWikiPage(), $context );
if ( $action instanceof Action ) {
return $action->getName();
}
public function addHelpLink( $to, $overrideBaseUrl = false ) {
global $wgContLang;
$msg = wfMessage( $wgContLang->lc(
- Action::getActionName( $this->getContext() )
+ self::getActionName( $this->getContext() )
) . '-helppage' );
if ( !$msg->isDisabled() ) {
// Main module has this method overridden
// Safety - avoid infinite loop:
if ( $this->isMain() ) {
- ApiBase::dieDebug( __METHOD__, 'base method was called on main module.' );
+ self::dieDebug( __METHOD__, 'base method was called on main module.' );
}
return $this->getMain()->lacksSameOriginSecurity();
// Main module has getResult() method overridden
// Safety - avoid infinite loop:
if ( $this->isMain() ) {
- ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' );
+ self::dieDebug( __METHOD__, 'base method was called on main module. ' );
}
return $this->getMain()->getResult();
// Main module has getErrorFormatter() method overridden
// Safety - avoid infinite loop:
if ( $this->isMain() ) {
- ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' );
+ self::dieDebug( __METHOD__, 'base method was called on main module. ' );
}
return $this->getMain()->getErrorFormatter();
// Main module has getContinuationManager() method overridden
// Safety - avoid infinite loop:
if ( $this->isMain() ) {
- ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' );
+ self::dieDebug( __METHOD__, 'base method was called on main module. ' );
}
return $this->getMain()->getContinuationManager();
// Main module has setContinuationManager() method overridden
// Safety - avoid infinite loop:
if ( $this->isMain() ) {
- ApiBase::dieDebug( __METHOD__, 'base method was called on main module. ' );
+ self::dieDebug( __METHOD__, 'base method was called on main module. ' );
}
$this->getMain()->setContinuationManager( $manager );
if ( $type == 'boolean' ) {
if ( isset( $default ) && $default !== false ) {
// Having a default value of anything other than 'false' is not allowed
- ApiBase::dieDebug(
+ self::dieDebug(
__METHOD__,
"Boolean param $encParamName's default is set to '$default'. " .
'Boolean parameters must default to false.'
} elseif ( $type == 'upload' ) {
if ( isset( $default ) ) {
// Having a default value is not allowed
- ApiBase::dieDebug(
+ self::dieDebug(
__METHOD__,
"File upload param $encParamName's default is set to " .
"'$default'. File upload parameters may not have a default." );
}
if ( $multi ) {
- ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
+ self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
}
$value = $this->getMain()->getUpload( $encParamName );
if ( !$value->exists() ) {
$allSpecifier = ( is_string( $allowAll ) ? $allowAll : self::ALL_DEFAULT_STRING );
if ( $allowAll && $multi && is_array( $type ) && in_array( $allSpecifier, $type, true ) ) {
- ApiBase::dieDebug(
+ self::dieDebug(
__METHOD__,
"For param $encParamName, PARAM_ALL collides with a possible value" );
}
if ( !isset( $paramSettings[self::PARAM_MAX] )
|| !isset( $paramSettings[self::PARAM_MAX2] )
) {
- ApiBase::dieDebug(
+ self::dieDebug(
__METHOD__,
"MAX1 or MAX2 are not defined for the limit $encParamName"
);
}
if ( $multi ) {
- ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
+ self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
}
$min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0;
if ( $value == 'max' ) {
break;
case 'boolean':
if ( $multi ) {
- ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
+ self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
}
break;
case 'timestamp':
}
break;
default:
- ApiBase::dieDebug( __METHOD__, "Param $encParamName's type is unknown - $type" );
+ self::dieDebug( __METHOD__, "Param $encParamName's type is unknown - $type" );
}
}
* @return Message
*/
public function getFinalSummary() {
- $msg = ApiBase::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
+ $msg = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
$this->getModulePrefix(),
$this->getModuleName(),
$this->getModulePath(),
] );
if ( !$msg->exists() ) {
wfDeprecated( 'API help "description" messages', '1.30' );
- $msg = ApiBase::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [
+ $msg = self::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [
$this->getModulePrefix(),
$this->getModuleName(),
$this->getModulePath(),
] );
- $msg = ApiBase::makeMessage( 'rawmessage', $this->getContext(), [
+ $msg = self::makeMessage( 'rawmessage', $this->getContext(), [
preg_replace( '/\n.*/s', '', $msg->text() )
] );
}
$desc = (string)$desc;
}
- $summary = ApiBase::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
+ $summary = self::makeMessage( $this->getSummaryMessage(), $this->getContext(), [
$this->getModulePrefix(),
$this->getModuleName(),
$this->getModulePath(),
] );
- $extendedDescription = ApiBase::makeMessage(
+ $extendedDescription = self::makeMessage(
$this->getExtendedDescription(), $this->getContext(), [
$this->getModulePrefix(),
$this->getModuleName(),
$msgs = [ $summary, $extendedDescription ];
} else {
wfDeprecated( 'API help "description" messages', '1.30' );
- $description = ApiBase::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [
+ $description = self::makeMessage( $this->getDescriptionMessage(), $this->getContext(), [
$this->getModulePrefix(),
$this->getModuleName(),
$this->getModulePath(),
if ( $this->needsToken() ) {
$params['token'] = [
- ApiBase::PARAM_TYPE => 'string',
- ApiBase::PARAM_REQUIRED => true,
- ApiBase::PARAM_SENSITIVE => true,
- ApiBase::PARAM_HELP_MSG => [
+ self::PARAM_TYPE => 'string',
+ self::PARAM_REQUIRED => true,
+ self::PARAM_SENSITIVE => true,
+ self::PARAM_HELP_MSG => [
'api-help-param-token',
$this->needsToken(),
],
}
$desc = self::escapeWikiText( $desc );
- $params = $this->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
+ $params = $this->getFinalParams( self::GET_VALUES_FOR_HELP );
$msgs = [];
foreach ( $params as $param => $settings ) {
if ( !is_array( $settings ) ) {
$d = implode( ' ', $d );
}
- if ( isset( $settings[ApiBase::PARAM_HELP_MSG] ) ) {
- $msg = $settings[ApiBase::PARAM_HELP_MSG];
+ if ( isset( $settings[self::PARAM_HELP_MSG] ) ) {
+ $msg = $settings[self::PARAM_HELP_MSG];
} else {
$msg = $this->msg( "apihelp-{$path}-param-{$param}" );
if ( !$msg->exists() ) {
$msg = $this->msg( 'api-help-fallback-parameter', $d );
}
}
- $msg = ApiBase::makeMessage( $msg, $this->getContext(),
+ $msg = self::makeMessage( $msg, $this->getContext(),
[ $prefix, $param, $name, $path ] );
if ( !$msg ) {
self::dieDebug( __METHOD__,
}
$msgs[$param] = [ $msg ];
- if ( isset( $settings[ApiBase::PARAM_TYPE] ) &&
- $settings[ApiBase::PARAM_TYPE] === 'submodule'
+ if ( isset( $settings[self::PARAM_TYPE] ) &&
+ $settings[self::PARAM_TYPE] === 'submodule'
) {
- if ( isset( $settings[ApiBase::PARAM_SUBMODULE_MAP] ) ) {
- $map = $settings[ApiBase::PARAM_SUBMODULE_MAP];
+ if ( isset( $settings[self::PARAM_SUBMODULE_MAP] ) ) {
+ $map = $settings[self::PARAM_SUBMODULE_MAP];
} else {
$prefix = $this->isMain() ? '' : ( $this->getModulePath() . '+' );
$map = [];
$arr[] = $m->setContext( $this->getContext() );
}
$msgs[$param] = array_merge( $msgs[$param], $submodules, $deprecatedSubmodules );
- } elseif ( isset( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) {
- if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE] ) ) {
+ } elseif ( isset( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) {
+ if ( !is_array( $settings[self::PARAM_HELP_MSG_PER_VALUE] ) ) {
self::dieDebug( __METHOD__,
'ApiBase::PARAM_HELP_MSG_PER_VALUE is not valid' );
}
- if ( !is_array( $settings[ApiBase::PARAM_TYPE] ) ) {
+ if ( !is_array( $settings[self::PARAM_TYPE] ) ) {
self::dieDebug( __METHOD__,
'ApiBase::PARAM_HELP_MSG_PER_VALUE may only be used when ' .
'ApiBase::PARAM_TYPE is an array' );
}
- $valueMsgs = $settings[ApiBase::PARAM_HELP_MSG_PER_VALUE];
- $deprecatedValues = isset( $settings[ApiBase::PARAM_DEPRECATED_VALUES] )
- ? $settings[ApiBase::PARAM_DEPRECATED_VALUES]
+ $valueMsgs = $settings[self::PARAM_HELP_MSG_PER_VALUE];
+ $deprecatedValues = isset( $settings[self::PARAM_DEPRECATED_VALUES] )
+ ? $settings[self::PARAM_DEPRECATED_VALUES]
: [];
- foreach ( $settings[ApiBase::PARAM_TYPE] as $value ) {
+ foreach ( $settings[self::PARAM_TYPE] as $value ) {
if ( isset( $valueMsgs[$value] ) ) {
$msg = $valueMsgs[$value];
} else {
$msg = "apihelp-{$path}-paramvalue-{$param}-{$value}";
}
- $m = ApiBase::makeMessage( $msg, $this->getContext(),
+ $m = self::makeMessage( $msg, $this->getContext(),
[ $prefix, $param, $name, $path, $value ] );
if ( $m ) {
$m = new ApiHelpParamValueMessage(
}
}
- if ( isset( $settings[ApiBase::PARAM_HELP_MSG_APPEND] ) ) {
- if ( !is_array( $settings[ApiBase::PARAM_HELP_MSG_APPEND] ) ) {
+ if ( isset( $settings[self::PARAM_HELP_MSG_APPEND] ) ) {
+ if ( !is_array( $settings[self::PARAM_HELP_MSG_APPEND] ) ) {
self::dieDebug( __METHOD__,
'Value for ApiBase::PARAM_HELP_MSG_APPEND is not an array' );
}
- foreach ( $settings[ApiBase::PARAM_HELP_MSG_APPEND] as $m ) {
- $m = ApiBase::makeMessage( $m, $this->getContext(),
+ foreach ( $settings[self::PARAM_HELP_MSG_APPEND] as $m ) {
+ $m = self::makeMessage( $m, $this->getContext(),
[ $prefix, $param, $name, $path ] );
if ( $m ) {
$msgs[$param][] = $m;
ApiBase::PARAM_TYPE => 'submodule',
],
'format' => [
- ApiBase::PARAM_DFLT => ApiMain::API_DEFAULT_FORMAT,
+ ApiBase::PARAM_DFLT => self::API_DEFAULT_FORMAT,
ApiBase::PARAM_TYPE => 'submodule',
],
'maxlag' => [
public function __construct( ApiBase $dbSource, $flags = 0, $defaultNamespace = NS_MAIN ) {
parent::__construct( $dbSource->getMain(), $dbSource->getModuleName() );
$this->mDbSource = $dbSource;
- $this->mAllowGenerator = ( $flags & ApiPageSet::DISABLE_GENERATORS ) == 0;
+ $this->mAllowGenerator = ( $flags & self::DISABLE_GENERATORS ) == 0;
$this->mDefaultNamespace = $defaultNamespace;
$this->mParams = $this->extractRequestParams();
}
// Create a temporary pageset to store generator's output,
// add any additional fields generator may need, and execute pageset to populate titles/pageids
- $tmpPageSet = new ApiPageSet( $dbSource, ApiPageSet::DISABLE_GENERATORS );
+ $tmpPageSet = new ApiPageSet( $dbSource, self::DISABLE_GENERATORS );
$generator->setGeneratorMode( $tmpPageSet );
$this->mCacheMode = $generator->getCacheMode( $generator->extractRequestParams() );
ApiBase::PARAM_DFLT => -1,
ApiBase::PARAM_HELP_MSG => [
'apihelp-query+imageinfo-param-urlwidth',
- ApiQueryImageInfo::TRANSFORM_LIMIT,
+ self::TRANSFORM_LIMIT,
],
],
'urlheight' => [
* @deprecated since 1.24
*/
public static function resetTokenCache() {
- ApiQueryInfo::$cachedTokens = [];
+ self::$cachedTokens = [];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['edit'] ) ) {
- ApiQueryInfo::$cachedTokens['edit'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['edit'] ) ) {
+ self::$cachedTokens['edit'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['edit'];
+ return self::$cachedTokens['edit'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['delete'] ) ) {
- ApiQueryInfo::$cachedTokens['delete'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['delete'] ) ) {
+ self::$cachedTokens['delete'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['delete'];
+ return self::$cachedTokens['delete'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['protect'] ) ) {
- ApiQueryInfo::$cachedTokens['protect'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['protect'] ) ) {
+ self::$cachedTokens['protect'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['protect'];
+ return self::$cachedTokens['protect'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['move'] ) ) {
- ApiQueryInfo::$cachedTokens['move'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['move'] ) ) {
+ self::$cachedTokens['move'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['move'];
+ return self::$cachedTokens['move'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['block'] ) ) {
- ApiQueryInfo::$cachedTokens['block'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['block'] ) ) {
+ self::$cachedTokens['block'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['block'];
+ return self::$cachedTokens['block'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['email'] ) ) {
- ApiQueryInfo::$cachedTokens['email'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['email'] ) ) {
+ self::$cachedTokens['email'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['email'];
+ return self::$cachedTokens['email'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['import'] ) ) {
- ApiQueryInfo::$cachedTokens['import'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['import'] ) ) {
+ self::$cachedTokens['import'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['import'];
+ return self::$cachedTokens['import'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['watch'] ) ) {
- ApiQueryInfo::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' );
+ if ( !isset( self::$cachedTokens['watch'] ) ) {
+ self::$cachedTokens['watch'] = $wgUser->getEditToken( 'watch' );
}
- return ApiQueryInfo::$cachedTokens['watch'];
+ return self::$cachedTokens['watch'];
}
/**
}
// The token is always the same, let's exploit that
- if ( !isset( ApiQueryInfo::$cachedTokens['options'] ) ) {
- ApiQueryInfo::$cachedTokens['options'] = $wgUser->getEditToken();
+ if ( !isset( self::$cachedTokens['options'] ) ) {
+ self::$cachedTokens['options'] = $wgUser->getEditToken();
}
- return ApiQueryInfo::$cachedTokens['options'];
+ return self::$cachedTokens['options'];
}
public function execute() {
* @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP.
*/
public static function setValue( array &$arr, $name, $value, $flags = 0 ) {
- if ( ( $flags & ApiResult::NO_VALIDATE ) !== ApiResult::NO_VALIDATE ) {
+ if ( ( $flags & self::NO_VALIDATE ) !== self::NO_VALIDATE ) {
$value = self::validateValue( $value );
}
if ( $name === null ) {
- if ( $flags & ApiResult::ADD_ON_TOP ) {
+ if ( $flags & self::ADD_ON_TOP ) {
array_unshift( $arr, $value );
} else {
array_push( $arr, $value );
}
$exists = isset( $arr[$name] );
- if ( !$exists || ( $flags & ApiResult::OVERRIDE ) ) {
- if ( !$exists && ( $flags & ApiResult::ADD_ON_TOP ) ) {
+ if ( !$exists || ( $flags & self::OVERRIDE ) ) {
+ if ( !$exists && ( $flags & self::ADD_ON_TOP ) ) {
$arr = [ $name => $value ] + $arr;
} else {
$arr[$name] = $value;
* @since 1.21 int $flags replaced boolean $override
*/
public function addValue( $path, $name, $value, $flags = 0 ) {
- $arr = &$this->path( $path, ( $flags & ApiResult::ADD_ON_TOP ) ? 'prepend' : 'append' );
+ $arr = &$this->path( $path, ( $flags & self::ADD_ON_TOP ) ? 'prepend' : 'append' );
- if ( $this->checkingSize && !( $flags & ApiResult::NO_SIZE_CHECK ) ) {
+ if ( $this->checkingSize && !( $flags & self::NO_SIZE_CHECK ) ) {
// self::size needs the validated value. Then flag
// to not re-validate later.
$value = self::validateValue( $value );
- $flags |= ApiResult::NO_VALIDATE;
+ $flags |= self::NO_VALIDATE;
$newsize = $this->size + self::size( $value );
if ( $this->maxSize !== false && $newsize > $this->maxSize ) {
$name = array_pop( $path );
}
$ret = self::unsetValue( $this->path( $path, 'dummy' ), $name );
- if ( $this->checkingSize && !( $flags & ApiResult::NO_SIZE_CHECK ) ) {
+ if ( $this->checkingSize && !( $flags & self::NO_SIZE_CHECK ) ) {
$newsize = $this->size - self::size( $ret );
$this->size = max( $newsize, 0 );
}
public function addParsedLimit( $moduleName, $limit ) {
// Add value, allowing overwriting
$this->addValue( 'limits', $moduleName, $limit,
- ApiResult::OVERRIDE | ApiResult::NO_SIZE_CHECK );
+ self::OVERRIDE | self::NO_SIZE_CHECK );
}
/**@}*/
* @param int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP.
*/
public function addContentField( $path, $name, $flags = 0 ) {
- $arr = &$this->path( $path, ( $flags & ApiResult::ADD_ON_TOP ) ? 'prepend' : 'append' );
+ $arr = &$this->path( $path, ( $flags & self::ADD_ON_TOP ) ? 'prepend' : 'append' );
self::setContentField( $arr, $name, $flags );
}
$bools = [];
foreach ( $vars as $k => $v ) {
if ( is_array( $v ) || is_object( $v ) ) {
- $vars[$k] = ApiResult::addMetadataToResultVars( (array)$v, is_object( $v ) );
+ $vars[$k] = self::addMetadataToResultVars( (array)$v, is_object( $v ) );
} elseif ( is_bool( $v ) ) {
// Better here to use real bools even in BC formats
$bools[] = $k;
// Get the list of keys we actually care about. Unfortunately, we can't support
// certain keys that conflict with ApiResult metadata.
$keys = array_diff( array_keys( $vars ), [
- ApiResult::META_TYPE, ApiResult::META_PRESERVE_KEYS, ApiResult::META_KVP_KEY_NAME,
- ApiResult::META_INDEXED_TAG_NAME, ApiResult::META_BC_BOOLS
+ self::META_TYPE, self::META_PRESERVE_KEYS, self::META_KVP_KEY_NAME,
+ self::META_INDEXED_TAG_NAME, self::META_BC_BOOLS
] );
return [
- ApiResult::META_TYPE => 'kvp',
- ApiResult::META_KVP_KEY_NAME => 'key',
- ApiResult::META_PRESERVE_KEYS => $keys,
- ApiResult::META_BC_BOOLS => $bools,
- ApiResult::META_INDEXED_TAG_NAME => 'var',
+ self::META_TYPE => 'kvp',
+ self::META_KVP_KEY_NAME => 'key',
+ self::META_PRESERVE_KEYS => $keys,
+ self::META_BC_BOOLS => $bools,
+ self::META_INDEXED_TAG_NAME => 'var',
] + $vars;
} else {
return [
- ApiResult::META_TYPE => 'array',
- ApiResult::META_BC_BOOLS => $bools,
- ApiResult::META_INDEXED_TAG_NAME => 'value',
+ self::META_TYPE => 'array',
+ self::META_BC_BOOLS => $bools,
+ self::META_INDEXED_TAG_NAME => 'value',
] + $vars;
}
}
*/
public static function newPass( $username = null ) {
$ret = new AuthenticationResponse;
- $ret->status = AuthenticationResponse::PASS;
+ $ret->status = self::PASS;
$ret->username = $username;
return $ret;
}
*/
public static function newFail( Message $msg ) {
$ret = new AuthenticationResponse;
- $ret->status = AuthenticationResponse::FAIL;
+ $ret->status = self::FAIL;
$ret->message = $msg;
$ret->messageType = 'error';
return $ret;
*/
public static function newRestart( Message $msg ) {
$ret = new AuthenticationResponse;
- $ret->status = AuthenticationResponse::RESTART;
+ $ret->status = self::RESTART;
$ret->message = $msg;
return $ret;
}
*/
public static function newAbstain() {
$ret = new AuthenticationResponse;
- $ret->status = AuthenticationResponse::ABSTAIN;
+ $ret->status = self::ABSTAIN;
return $ret;
}
}
$ret = new AuthenticationResponse;
- $ret->status = AuthenticationResponse::UI;
+ $ret->status = self::UI;
$ret->neededRequests = $reqs;
$ret->message = $msg;
$ret->messageType = $msgtype;
}
$ret = new AuthenticationResponse;
- $ret->status = AuthenticationResponse::REDIRECT;
+ $ret->status = self::REDIRECT;
$ret->neededRequests = $reqs;
$ret->redirectTarget = $redirectTarget;
$ret->redirectApiData = $redirectApiData;
}
// Normalise title-case input (with some inlining)
- $lckey = MessageCache::normalizeKey( $key );
+ $lckey = self::normalizeKey( $key );
Hooks::run( 'MessageCache::get', [ &$lckey ] );
if ( is_array( $type ) ) {
$retval = [];
foreach ( $type as $t ) {
- $retval[] = RecentChange::parseToRCType( $t );
+ $retval[] = self::parseToRCType( $t );
}
return $retval;
$change = $change instanceof RecentChange
? $change
- : RecentChange::newFromId( $change );
+ : self::newFromId( $change );
if ( !$change instanceof RecentChange ) {
return null;
* @return string|bool
*/
static function getUnicodeVersionForICU() {
- $icuVersion = IcuCollation::getICUVersion();
+ $icuVersion = self::getICUVersion();
if ( !$icuVersion ) {
return false;
}
$modelId = $title->getContentModel();
}
- $handler = ContentHandler::getForModelID( $modelId );
+ $handler = self::getForModelID( $modelId );
return $handler->unserializeContent( $text, $format );
}
public static function getForTitle( Title $title ) {
$modelId = $title->getContentModel();
- return ContentHandler::getForModelID( $modelId );
+ return self::getForModelID( $modelId );
}
/**
public static function getForContent( Content $content ) {
$modelId = $content->getModel();
- return ContentHandler::getForModelID( $modelId );
+ return self::getForModelID( $modelId );
}
/**
public static function getForModelID( $modelId ) {
global $wgContentHandlers;
- if ( isset( ContentHandler::$handlers[$modelId] ) ) {
- return ContentHandler::$handlers[$modelId];
+ if ( isset( self::$handlers[$modelId] ) ) {
+ return self::$handlers[$modelId];
}
if ( empty( $wgContentHandlers[$modelId] ) ) {
wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId
. ': ' . get_class( $handler ) );
- ContentHandler::$handlers[$modelId] = $handler;
+ self::$handlers[$modelId] = $handler;
- return ContentHandler::$handlers[$modelId];
+ return self::$handlers[$modelId];
}
/**
$formats = [];
foreach ( $wgContentHandlers as $model => $class ) {
- $handler = ContentHandler::getForModelID( $model );
+ $handler = self::getForModelID( $model );
$formats = array_merge( $formats, $handler->getSupportedFormats() );
}
$html = '';
if ( self::$enabled ) {
- MWDebug::log( 'MWDebug output complete' );
+ self::log( 'MWDebug output complete' );
$debugInfo = self::getDebugInfo( $context );
// Cannot use OutputPage::addJsConfigVars because those are already outputted
}
}
- MWDebug::log( 'MWDebug output complete' );
+ self::log( 'MWDebug output complete' );
$debugInfo = self::getDebugInfo( $context );
ApiResult::setIndexedTagName( $debugInfo, 'debuginfo' );
* @param int $buffer One of WikiExporter::BUFFER or WikiExporter::STREAM
* @param int $text One of WikiExporter::TEXT or WikiExporter::STUB
*/
- function __construct( $db, $history = WikiExporter::CURRENT,
- $buffer = WikiExporter::BUFFER, $text = WikiExporter::TEXT ) {
+ function __construct( $db, $history = self::CURRENT,
+ $buffer = self::BUFFER, $text = self::TEXT ) {
$this->db = $db;
$this->history = $history;
$this->buffer = $buffer;
# Get logging table name for logging.* clause
$logging = $this->db->tableName( 'logging' );
- if ( $this->buffer == WikiExporter::STREAM ) {
+ if ( $this->buffer == self::STREAM ) {
$prev = $this->db->bufferResults( false );
}
$result = null; // Assuring $result is not undefined, if exception occurs early
[ 'ORDER BY' => 'log_id', 'USE INDEX' => [ 'logging' => 'PRIMARY' ] ]
);
$this->outputLogStream( $result );
- if ( $this->buffer == WikiExporter::STREAM ) {
+ if ( $this->buffer == self::STREAM ) {
$this->db->bufferResults( $prev );
}
} catch ( Exception $e ) {
// Putting database back in previous buffer mode
try {
- if ( $this->buffer == WikiExporter::STREAM ) {
+ if ( $this->buffer == self::STREAM ) {
$this->db->bufferResults( $prev );
}
} catch ( Exception $e2 ) {
if ( !empty( $this->history['limit'] ) ) {
$opts['LIMIT'] = intval( $this->history['limit'] );
}
- } elseif ( $this->history & WikiExporter::FULL ) {
+ } elseif ( $this->history & self::FULL ) {
# Full history dumps...
# query optimization for history stub dumps
- if ( $this->text == WikiExporter::STUB && $orderRevs ) {
+ if ( $this->text == self::STUB && $orderRevs ) {
$tables = [ 'revision', 'page' ];
$opts[] = 'STRAIGHT_JOIN';
$opts['ORDER BY'] = [ 'rev_page ASC', 'rev_id ASC' ];
} else {
$join['revision'] = [ 'INNER JOIN', 'page_id=rev_page' ];
}
- } elseif ( $this->history & WikiExporter::CURRENT ) {
+ } elseif ( $this->history & self::CURRENT ) {
# Latest revision dumps...
if ( $this->list_authors && $cond != '' ) { // List authors, if so desired
$this->do_list_authors( $cond );
}
$join['revision'] = [ 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' ];
- } elseif ( $this->history & WikiExporter::STABLE ) {
+ } elseif ( $this->history & self::STABLE ) {
# "Stable" revision dumps...
# Default JOIN, to be overridden...
$join['revision'] = [ 'INNER JOIN', 'page_id=rev_page AND page_latest=rev_id' ];
if ( Hooks::run( 'WikiExporter::dumpStableQuery', [ &$tables, &$opts, &$join ] ) ) {
throw new MWException( __METHOD__ . " given invalid history dump type." );
}
- } elseif ( $this->history & WikiExporter::RANGE ) {
+ } elseif ( $this->history & self::RANGE ) {
# Dump of revisions within a specified range
$join['revision'] = [ 'INNER JOIN', 'page_id=rev_page' ];
$opts['ORDER BY'] = [ 'rev_page ASC', 'rev_id ASC' ];
$opts['USE INDEX']['page'] = 'PRIMARY';
}
# Build text join options
- if ( $this->text != WikiExporter::STUB ) { // 1-pass
+ if ( $this->text != self::STUB ) { // 1-pass
$tables[] = 'text';
$join['text'] = [ 'INNER JOIN', 'rev_text_id=old_id' ];
}
- if ( $this->buffer == WikiExporter::STREAM ) {
+ if ( $this->buffer == self::STREAM ) {
$prev = $this->db->bufferResults( false );
}
$result = null; // Assuring $result is not undefined, if exception occurs early
# Output dump results
$this->outputPageStream( $result );
- if ( $this->buffer == WikiExporter::STREAM ) {
+ if ( $this->buffer == self::STREAM ) {
$this->db->bufferResults( $prev );
}
} catch ( Exception $e ) {
// Putting database back in previous buffer mode
try {
- if ( $this->buffer == WikiExporter::STREAM ) {
+ if ( $this->buffer == self::STREAM ) {
$this->db->bufferResults( $prev );
}
} catch ( Exception $e2 ) {
}
$req = MWHttpRequest::factory( $url, $options, __METHOD__ );
- $req->setUserAgent( ForeignAPIRepo::getUserAgent() );
+ $req->setUserAgent( self::getUserAgent() );
$status = $req->execute();
if ( $status->isOK() ) {
return ObjectFactory::constructClassInstance( OOUIHTMLForm::class, $arguments );
default:
/** @var HTMLForm $form */
- $form = ObjectFactory::constructClassInstance( HTMLForm::class, $arguments );
+ $form = ObjectFactory::constructClassInstance( self::class, $arguments );
$form->setDisplayFormat( $displayFormat );
return $form;
}
$options['timeout'] = $args[1];
$caller = __METHOD__;
}
- return Http::request( 'GET', $url, $options, $caller );
+ return self::request( 'GET', $url, $options, $caller );
}
/**
* @return string|bool false on error
*/
public static function post( $url, $options = [], $caller = __METHOD__ ) {
- return Http::request( 'POST', $url, $options, $caller );
+ return self::request( 'POST', $url, $options, $caller );
}
/**
}
$fname = $upload['tmp_name'];
if ( is_uploaded_file( $fname ) ) {
- return ImportStreamSource::newFromFile( $fname );
+ return self::newFromFile( $fname );
} else {
return Status::newFatal( 'importnofile' );
}
$url = wfAppendQuery( $link, $params );
# For interwikis, use POST to avoid redirects.
- return ImportStreamSource::newFromURL( $url, "POST" );
+ return self::newFromURL( $url, "POST" );
}
}
// Flag this job as an old duplicate based on its "root" job...
try {
if ( $job && $this->isRootJobOldDuplicate( $job ) ) {
- JobQueue::incrStats( 'dupe_pops', $this->type );
+ self::incrStats( 'dupe_pops', $this->type );
$job = DuplicateJob::newFromJob( $job ); // convert to a no-op
}
} catch ( Exception $e ) {
// quotation marks (e.g. "foo /* bar").
$comments = [];
- $pattern = '/(?!' . CSSMin::EMBED_REGEX . ')(' . CSSMin::COMMENT_REGEX . ')/s';
+ $pattern = '/(?!' . self::EMBED_REGEX . ')(' . self::COMMENT_REGEX . ')/s';
$source = preg_replace_callback(
$pattern,
}, $source );
// Re-insert comments
- $pattern = '/' . CSSMin::PLACEHOLDER . '(\d+)x/';
+ $pattern = '/' . self::PLACEHOLDER . '(\d+)x/';
$source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) {
return $comments[ $match[1] ];
}, $source );
*/
private static function parseCIDR6( $range ) {
# Explode into <expanded IP,range>
- $parts = explode( '/', IP::sanitizeIP( $range ), 2 );
+ $parts = explode( '/', self::sanitizeIP( $range ), 2 );
if ( count( $parts ) != 2 ) {
return [ false, false ];
}
*/
private static function parseRange6( $range ) {
# Expand any IPv6 IP
- $range = IP::sanitizeIP( $range );
+ $range = self::sanitizeIP( $range );
// CIDR notation...
if ( strpos( $range, '/' ) !== false ) {
list( $network, $bits ) = self::parseCIDR6( $range );
public static function getSubnet( $ip ) {
$matches = [];
$subnet = false;
- if ( IP::isIPv6( $ip ) ) {
- $parts = IP::parseRange( "$ip/64" );
+ if ( self::isIPv6( $ip ) ) {
+ $parts = self::parseRange( "$ip/64" );
$subnet = $parts[0];
} elseif ( preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) {
// IPv4
// Replace instances of the separator inside HTML-like tags with the placeholder
$replacer = new DoubleReplacer( $separator, $placeholder );
- $cleaned = StringUtils::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text );
+ $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text );
// Explode, then put the replaced separators back in
$items = explode( $separator, $cleaned );
// Replace instances of the separator inside HTML-like tags with the placeholder
$replacer = new DoubleReplacer( $search, $placeholder );
- $cleaned = StringUtils::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text );
+ $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text );
// Explode, then put the replaced separators back in
$cleaned = str_replace( $search, $replace, $cleaned );
* @return bool
*/
public static function isLogType( $type ) {
- return in_array( $type, LogPage::validTypes() );
+ return in_array( $type, self::validTypes() );
}
/**
$this->action = $action;
$this->target = $target;
$this->comment = $comment;
- $this->params = LogPage::makeParamBlob( $params );
+ $this->params = self::makeParamBlob( $params );
if ( $doer === null ) {
global $wgUser;
// first send to non-split address list, then to split addresses one by one
$status = Status::newGood();
if ( $to ) {
- $status->merge( UserMailer::sendInternal(
+ $status->merge( self::sendInternal(
$to, $from, $subject, $body, $options ) );
}
foreach ( $splitTo as $newTo ) {
- $status->merge( UserMailer::sendInternal(
+ $status->merge( self::sendInternal(
[ $newTo ], $from, $subject, $body, $options ) );
}
return $status;
}
}
- return UserMailer::sendInternal( $to, $from, $subject, $body, $options );
+ return self::sendInternal( $to, $from, $subject, $body, $options );
}
/**
# TIFF Rev. 6.0 Attribute Information (p22)
'IFD0' => [
# Tags relating to image structure
- 'ImageWidth' => Exif::SHORT_OR_LONG, # Image width
- 'ImageLength' => Exif::SHORT_OR_LONG, # Image height
- 'BitsPerSample' => [ Exif::SHORT, 3 ], # Number of bits per component
+ 'ImageWidth' => self::SHORT_OR_LONG, # Image width
+ 'ImageLength' => self::SHORT_OR_LONG, # Image height
+ 'BitsPerSample' => [ self::SHORT, 3 ], # Number of bits per component
# "When a primary image is JPEG compressed, this designation is not"
# "necessary and is omitted." (p23)
- 'Compression' => Exif::SHORT, # Compression scheme #p23
- 'PhotometricInterpretation' => Exif::SHORT, # Pixel composition #p23
- 'Orientation' => Exif::SHORT, # Orientation of image #p24
- 'SamplesPerPixel' => Exif::SHORT, # Number of components
- 'PlanarConfiguration' => Exif::SHORT, # Image data arrangement #p24
- 'YCbCrSubSampling' => [ Exif::SHORT, 2 ], # Subsampling ratio of Y to C #p24
- 'YCbCrPositioning' => Exif::SHORT, # Y and C positioning #p24-25
- 'XResolution' => Exif::RATIONAL, # Image resolution in width direction
- 'YResolution' => Exif::RATIONAL, # Image resolution in height direction
- 'ResolutionUnit' => Exif::SHORT, # Unit of X and Y resolution #(p26)
+ 'Compression' => self::SHORT, # Compression scheme #p23
+ 'PhotometricInterpretation' => self::SHORT, # Pixel composition #p23
+ 'Orientation' => self::SHORT, # Orientation of image #p24
+ 'SamplesPerPixel' => self::SHORT, # Number of components
+ 'PlanarConfiguration' => self::SHORT, # Image data arrangement #p24
+ 'YCbCrSubSampling' => [ self::SHORT, 2 ], # Subsampling ratio of Y to C #p24
+ 'YCbCrPositioning' => self::SHORT, # Y and C positioning #p24-25
+ 'XResolution' => self::RATIONAL, # Image resolution in width direction
+ 'YResolution' => self::RATIONAL, # Image resolution in height direction
+ 'ResolutionUnit' => self::SHORT, # Unit of X and Y resolution #(p26)
# Tags relating to recording offset
- 'StripOffsets' => Exif::SHORT_OR_LONG, # Image data location
- 'RowsPerStrip' => Exif::SHORT_OR_LONG, # Number of rows per strip
- 'StripByteCounts' => Exif::SHORT_OR_LONG, # Bytes per compressed strip
- 'JPEGInterchangeFormat' => Exif::SHORT_OR_LONG, # Offset to JPEG SOI
- 'JPEGInterchangeFormatLength' => Exif::SHORT_OR_LONG, # Bytes of JPEG data
+ 'StripOffsets' => self::SHORT_OR_LONG, # Image data location
+ 'RowsPerStrip' => self::SHORT_OR_LONG, # Number of rows per strip
+ 'StripByteCounts' => self::SHORT_OR_LONG, # Bytes per compressed strip
+ 'JPEGInterchangeFormat' => self::SHORT_OR_LONG, # Offset to JPEG SOI
+ 'JPEGInterchangeFormatLength' => self::SHORT_OR_LONG, # Bytes of JPEG data
# Tags relating to image data characteristics
- 'TransferFunction' => Exif::IGNORE, # Transfer function
- 'WhitePoint' => [ Exif::RATIONAL, 2 ], # White point chromaticity
- 'PrimaryChromaticities' => [ Exif::RATIONAL, 6 ], # Chromaticities of primarities
+ 'TransferFunction' => self::IGNORE, # Transfer function
+ 'WhitePoint' => [ self::RATIONAL, 2 ], # White point chromaticity
+ 'PrimaryChromaticities' => [ self::RATIONAL, 6 ], # Chromaticities of primarities
# Color space transformation matrix coefficients #p27
- 'YCbCrCoefficients' => [ Exif::RATIONAL, 3 ],
- 'ReferenceBlackWhite' => [ Exif::RATIONAL, 6 ], # Pair of black and white reference values
+ 'YCbCrCoefficients' => [ self::RATIONAL, 3 ],
+ 'ReferenceBlackWhite' => [ self::RATIONAL, 6 ], # Pair of black and white reference values
# Other tags
- 'DateTime' => Exif::ASCII, # File change date and time
- 'ImageDescription' => Exif::ASCII, # Image title
- 'Make' => Exif::ASCII, # Image input equipment manufacturer
- 'Model' => Exif::ASCII, # Image input equipment model
- 'Software' => Exif::ASCII, # Software used
- 'Artist' => Exif::ASCII, # Person who created the image
- 'Copyright' => Exif::ASCII, # Copyright holder
+ 'DateTime' => self::ASCII, # File change date and time
+ 'ImageDescription' => self::ASCII, # Image title
+ 'Make' => self::ASCII, # Image input equipment manufacturer
+ 'Model' => self::ASCII, # Image input equipment model
+ 'Software' => self::ASCII, # Software used
+ 'Artist' => self::ASCII, # Person who created the image
+ 'Copyright' => self::ASCII, # Copyright holder
],
# Exif IFD Attribute Information (p30-31)
'EXIF' => [
# @todo NOTE: Nonexistence of this field is taken to mean nonconformance
# to the Exif 2.1 AND 2.2 standards
- 'ExifVersion' => Exif::UNDEFINED, # Exif version
- 'FlashPixVersion' => Exif::UNDEFINED, # Supported Flashpix version #p32
+ 'ExifVersion' => self::UNDEFINED, # Exif version
+ 'FlashPixVersion' => self::UNDEFINED, # Supported Flashpix version #p32
# Tags relating to Image Data Characteristics
- 'ColorSpace' => Exif::SHORT, # Color space information #p32
+ 'ColorSpace' => self::SHORT, # Color space information #p32
# Tags relating to image configuration
- 'ComponentsConfiguration' => Exif::UNDEFINED, # Meaning of each component #p33
- 'CompressedBitsPerPixel' => Exif::RATIONAL, # Image compression mode
- 'PixelYDimension' => Exif::SHORT_OR_LONG, # Valid image height
- 'PixelXDimension' => Exif::SHORT_OR_LONG, # Valid image width
+ 'ComponentsConfiguration' => self::UNDEFINED, # Meaning of each component #p33
+ 'CompressedBitsPerPixel' => self::RATIONAL, # Image compression mode
+ 'PixelYDimension' => self::SHORT_OR_LONG, # Valid image height
+ 'PixelXDimension' => self::SHORT_OR_LONG, # Valid image width
# Tags relating to related user information
- 'MakerNote' => Exif::IGNORE, # Manufacturer notes
- 'UserComment' => Exif::UNDEFINED, # User comments #p34
+ 'MakerNote' => self::IGNORE, # Manufacturer notes
+ 'UserComment' => self::UNDEFINED, # User comments #p34
# Tags relating to related file information
- 'RelatedSoundFile' => Exif::ASCII, # Related audio file
+ 'RelatedSoundFile' => self::ASCII, # Related audio file
# Tags relating to date and time
- 'DateTimeOriginal' => Exif::ASCII, # Date and time of original data generation #p36
- 'DateTimeDigitized' => Exif::ASCII, # Date and time of original data generation
- 'SubSecTime' => Exif::ASCII, # DateTime subseconds
- 'SubSecTimeOriginal' => Exif::ASCII, # DateTimeOriginal subseconds
- 'SubSecTimeDigitized' => Exif::ASCII, # DateTimeDigitized subseconds
+ 'DateTimeOriginal' => self::ASCII, # Date and time of original data generation #p36
+ 'DateTimeDigitized' => self::ASCII, # Date and time of original data generation
+ 'SubSecTime' => self::ASCII, # DateTime subseconds
+ 'SubSecTimeOriginal' => self::ASCII, # DateTimeOriginal subseconds
+ 'SubSecTimeDigitized' => self::ASCII, # DateTimeDigitized subseconds
# Tags relating to picture-taking conditions (p31)
- 'ExposureTime' => Exif::RATIONAL, # Exposure time
- 'FNumber' => Exif::RATIONAL, # F Number
- 'ExposureProgram' => Exif::SHORT, # Exposure Program #p38
- 'SpectralSensitivity' => Exif::ASCII, # Spectral sensitivity
- 'ISOSpeedRatings' => Exif::SHORT, # ISO speed rating
- 'OECF' => Exif::IGNORE,
+ 'ExposureTime' => self::RATIONAL, # Exposure time
+ 'FNumber' => self::RATIONAL, # F Number
+ 'ExposureProgram' => self::SHORT, # Exposure Program #p38
+ 'SpectralSensitivity' => self::ASCII, # Spectral sensitivity
+ 'ISOSpeedRatings' => self::SHORT, # ISO speed rating
+ 'OECF' => self::IGNORE,
# Optoelectronic conversion factor. Note: We don't have support for this atm.
- 'ShutterSpeedValue' => Exif::SRATIONAL, # Shutter speed
- 'ApertureValue' => Exif::RATIONAL, # Aperture
- 'BrightnessValue' => Exif::SRATIONAL, # Brightness
- 'ExposureBiasValue' => Exif::SRATIONAL, # Exposure bias
- 'MaxApertureValue' => Exif::RATIONAL, # Maximum land aperture
- 'SubjectDistance' => Exif::RATIONAL, # Subject distance
- 'MeteringMode' => Exif::SHORT, # Metering mode #p40
- 'LightSource' => Exif::SHORT, # Light source #p40-41
- 'Flash' => Exif::SHORT, # Flash #p41-42
- 'FocalLength' => Exif::RATIONAL, # Lens focal length
- 'SubjectArea' => [ Exif::SHORT, 4 ], # Subject area
- 'FlashEnergy' => Exif::RATIONAL, # Flash energy
- 'SpatialFrequencyResponse' => Exif::IGNORE, # Spatial frequency response. Not supported atm.
- 'FocalPlaneXResolution' => Exif::RATIONAL, # Focal plane X resolution
- 'FocalPlaneYResolution' => Exif::RATIONAL, # Focal plane Y resolution
- 'FocalPlaneResolutionUnit' => Exif::SHORT, # Focal plane resolution unit #p46
- 'SubjectLocation' => [ Exif::SHORT, 2 ], # Subject location
- 'ExposureIndex' => Exif::RATIONAL, # Exposure index
- 'SensingMethod' => Exif::SHORT, # Sensing method #p46
- 'FileSource' => Exif::UNDEFINED, # File source #p47
- 'SceneType' => Exif::UNDEFINED, # Scene type #p47
- 'CFAPattern' => Exif::IGNORE, # CFA pattern. not supported atm.
- 'CustomRendered' => Exif::SHORT, # Custom image processing #p48
- 'ExposureMode' => Exif::SHORT, # Exposure mode #p48
- 'WhiteBalance' => Exif::SHORT, # White Balance #p49
- 'DigitalZoomRatio' => Exif::RATIONAL, # Digital zoom ration
- 'FocalLengthIn35mmFilm' => Exif::SHORT, # Focal length in 35 mm film
- 'SceneCaptureType' => Exif::SHORT, # Scene capture type #p49
- 'GainControl' => Exif::SHORT, # Scene control #p49-50
- 'Contrast' => Exif::SHORT, # Contrast #p50
- 'Saturation' => Exif::SHORT, # Saturation #p50
- 'Sharpness' => Exif::SHORT, # Sharpness #p50
- 'DeviceSettingDescription' => Exif::IGNORE,
+ 'ShutterSpeedValue' => self::SRATIONAL, # Shutter speed
+ 'ApertureValue' => self::RATIONAL, # Aperture
+ 'BrightnessValue' => self::SRATIONAL, # Brightness
+ 'ExposureBiasValue' => self::SRATIONAL, # Exposure bias
+ 'MaxApertureValue' => self::RATIONAL, # Maximum land aperture
+ 'SubjectDistance' => self::RATIONAL, # Subject distance
+ 'MeteringMode' => self::SHORT, # Metering mode #p40
+ 'LightSource' => self::SHORT, # Light source #p40-41
+ 'Flash' => self::SHORT, # Flash #p41-42
+ 'FocalLength' => self::RATIONAL, # Lens focal length
+ 'SubjectArea' => [ self::SHORT, 4 ], # Subject area
+ 'FlashEnergy' => self::RATIONAL, # Flash energy
+ 'SpatialFrequencyResponse' => self::IGNORE, # Spatial frequency response. Not supported atm.
+ 'FocalPlaneXResolution' => self::RATIONAL, # Focal plane X resolution
+ 'FocalPlaneYResolution' => self::RATIONAL, # Focal plane Y resolution
+ 'FocalPlaneResolutionUnit' => self::SHORT, # Focal plane resolution unit #p46
+ 'SubjectLocation' => [ self::SHORT, 2 ], # Subject location
+ 'ExposureIndex' => self::RATIONAL, # Exposure index
+ 'SensingMethod' => self::SHORT, # Sensing method #p46
+ 'FileSource' => self::UNDEFINED, # File source #p47
+ 'SceneType' => self::UNDEFINED, # Scene type #p47
+ 'CFAPattern' => self::IGNORE, # CFA pattern. not supported atm.
+ 'CustomRendered' => self::SHORT, # Custom image processing #p48
+ 'ExposureMode' => self::SHORT, # Exposure mode #p48
+ 'WhiteBalance' => self::SHORT, # White Balance #p49
+ 'DigitalZoomRatio' => self::RATIONAL, # Digital zoom ration
+ 'FocalLengthIn35mmFilm' => self::SHORT, # Focal length in 35 mm film
+ 'SceneCaptureType' => self::SHORT, # Scene capture type #p49
+ 'GainControl' => self::SHORT, # Scene control #p49-50
+ 'Contrast' => self::SHORT, # Contrast #p50
+ 'Saturation' => self::SHORT, # Saturation #p50
+ 'Sharpness' => self::SHORT, # Sharpness #p50
+ 'DeviceSettingDescription' => self::IGNORE,
# Device settings description. This could maybe be supported. Need to find an
# example file that uses this to see if it has stuff of interest in it.
- 'SubjectDistanceRange' => Exif::SHORT, # Subject distance range #p51
+ 'SubjectDistanceRange' => self::SHORT, # Subject distance range #p51
- 'ImageUniqueID' => Exif::ASCII, # Unique image ID
+ 'ImageUniqueID' => self::ASCII, # Unique image ID
],
# GPS Attribute Information (p52)
'GPS' => [
- 'GPSVersion' => Exif::UNDEFINED,
+ 'GPSVersion' => self::UNDEFINED,
# Should be an array of 4 Exif::BYTE's. However php treats it as an undefined
# Note exif standard calls this GPSVersionID, but php doesn't like the id suffix
- 'GPSLatitudeRef' => Exif::ASCII, # North or South Latitude #p52-53
- 'GPSLatitude' => [ Exif::RATIONAL, 3 ], # Latitude
- 'GPSLongitudeRef' => Exif::ASCII, # East or West Longitude #p53
- 'GPSLongitude' => [ Exif::RATIONAL, 3 ], # Longitude
- 'GPSAltitudeRef' => Exif::UNDEFINED,
+ 'GPSLatitudeRef' => self::ASCII, # North or South Latitude #p52-53
+ 'GPSLatitude' => [ self::RATIONAL, 3 ], # Latitude
+ 'GPSLongitudeRef' => self::ASCII, # East or West Longitude #p53
+ 'GPSLongitude' => [ self::RATIONAL, 3 ], # Longitude
+ 'GPSAltitudeRef' => self::UNDEFINED,
# Altitude reference. Note, the exif standard says this should be an EXIF::Byte,
# but php seems to disagree.
- 'GPSAltitude' => Exif::RATIONAL, # Altitude
- 'GPSTimeStamp' => [ Exif::RATIONAL, 3 ], # GPS time (atomic clock)
- 'GPSSatellites' => Exif::ASCII, # Satellites used for measurement
- 'GPSStatus' => Exif::ASCII, # Receiver status #p54
- 'GPSMeasureMode' => Exif::ASCII, # Measurement mode #p54-55
- 'GPSDOP' => Exif::RATIONAL, # Measurement precision
- 'GPSSpeedRef' => Exif::ASCII, # Speed unit #p55
- 'GPSSpeed' => Exif::RATIONAL, # Speed of GPS receiver
- 'GPSTrackRef' => Exif::ASCII, # Reference for direction of movement #p55
- 'GPSTrack' => Exif::RATIONAL, # Direction of movement
- 'GPSImgDirectionRef' => Exif::ASCII, # Reference for direction of image #p56
- 'GPSImgDirection' => Exif::RATIONAL, # Direction of image
- 'GPSMapDatum' => Exif::ASCII, # Geodetic survey data used
- 'GPSDestLatitudeRef' => Exif::ASCII, # Reference for latitude of destination #p56
- 'GPSDestLatitude' => [ Exif::RATIONAL, 3 ], # Latitude destination
- 'GPSDestLongitudeRef' => Exif::ASCII, # Reference for longitude of destination #p57
- 'GPSDestLongitude' => [ Exif::RATIONAL, 3 ], # Longitude of destination
- 'GPSDestBearingRef' => Exif::ASCII, # Reference for bearing of destination #p57
- 'GPSDestBearing' => Exif::RATIONAL, # Bearing of destination
- 'GPSDestDistanceRef' => Exif::ASCII, # Reference for distance to destination #p57-58
- 'GPSDestDistance' => Exif::RATIONAL, # Distance to destination
- 'GPSProcessingMethod' => Exif::UNDEFINED, # Name of GPS processing method
- 'GPSAreaInformation' => Exif::UNDEFINED, # Name of GPS area
- 'GPSDateStamp' => Exif::ASCII, # GPS date
- 'GPSDifferential' => Exif::SHORT, # GPS differential correction
+ 'GPSAltitude' => self::RATIONAL, # Altitude
+ 'GPSTimeStamp' => [ self::RATIONAL, 3 ], # GPS time (atomic clock)
+ 'GPSSatellites' => self::ASCII, # Satellites used for measurement
+ 'GPSStatus' => self::ASCII, # Receiver status #p54
+ 'GPSMeasureMode' => self::ASCII, # Measurement mode #p54-55
+ 'GPSDOP' => self::RATIONAL, # Measurement precision
+ 'GPSSpeedRef' => self::ASCII, # Speed unit #p55
+ 'GPSSpeed' => self::RATIONAL, # Speed of GPS receiver
+ 'GPSTrackRef' => self::ASCII, # Reference for direction of movement #p55
+ 'GPSTrack' => self::RATIONAL, # Direction of movement
+ 'GPSImgDirectionRef' => self::ASCII, # Reference for direction of image #p56
+ 'GPSImgDirection' => self::RATIONAL, # Direction of image
+ 'GPSMapDatum' => self::ASCII, # Geodetic survey data used
+ 'GPSDestLatitudeRef' => self::ASCII, # Reference for latitude of destination #p56
+ 'GPSDestLatitude' => [ self::RATIONAL, 3 ], # Latitude destination
+ 'GPSDestLongitudeRef' => self::ASCII, # Reference for longitude of destination #p57
+ 'GPSDestLongitude' => [ self::RATIONAL, 3 ], # Longitude of destination
+ 'GPSDestBearingRef' => self::ASCII, # Reference for bearing of destination #p57
+ 'GPSDestBearing' => self::RATIONAL, # Bearing of destination
+ 'GPSDestDistanceRef' => self::ASCII, # Reference for distance to destination #p57-58
+ 'GPSDestDistance' => self::RATIONAL, # Distance to destination
+ 'GPSProcessingMethod' => self::UNDEFINED, # Name of GPS processing method
+ 'GPSAreaInformation' => self::UNDEFINED, # Name of GPS area
+ 'GPSDateStamp' => self::ASCII, # GPS date
+ 'GPSDifferential' => self::SHORT, # GPS differential correction
],
];
}
// Does not work if not typecast
switch ( (string)$etype ) {
- case (string)Exif::BYTE:
+ case (string)self::BYTE:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isByte( $val );
- case (string)Exif::ASCII:
+ case (string)self::ASCII:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isASCII( $val );
- case (string)Exif::SHORT:
+ case (string)self::SHORT:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isShort( $val );
- case (string)Exif::LONG:
+ case (string)self::LONG:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isLong( $val );
- case (string)Exif::RATIONAL:
+ case (string)self::RATIONAL:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isRational( $val );
- case (string)Exif::SHORT_OR_LONG:
+ case (string)self::SHORT_OR_LONG:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isShort( $val ) || $this->isLong( $val );
- case (string)Exif::UNDEFINED:
+ case (string)self::UNDEFINED:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isUndefined( $val );
- case (string)Exif::SLONG:
+ case (string)self::SLONG:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isSlong( $val );
- case (string)Exif::SRATIONAL:
+ case (string)self::SRATIONAL:
$this->debug( $val, __FUNCTION__, $debug );
return $this->isSrational( $val );
- case (string)Exif::IGNORE:
+ case (string)self::IGNORE:
$this->debug( $val, __FUNCTION__, $debug );
return false;
}
// Clear caches
- WikiPage::onArticleDelete( $this->mTitle );
+ self::onArticleDelete( $this->mTitle );
ResourceLoaderWikiModule::invalidateModuleCache(
$this->mTitle, $revision, null, wfWikiID()
);
* @return bool
*/
protected function getDefaultDirections() {
- return IndexPager::DIR_ASCENDING;
+ return self::DIR_ASCENDING;
}
}
* @var string Deprecated accessor for the strip marker prefix.
* @deprecated since 1.26; use Parser::MARKER_PREFIX instead.
*/
- public $mUniqPrefix = Parser::MARKER_PREFIX;
+ public $mUniqPrefix = self::MARKER_PREFIX;
/**
* @var array Array with the language name of each language link (i.e. the
if ( !$frame->depth ) {
$flag = 0;
} else {
- $flag = Parser::PTD_FOR_INCLUSION;
+ $flag = self::PTD_FOR_INCLUSION;
}
$dom = $this->preprocessToDom( $text, $flag );
$text = $frame->expand( $dom );
$text = $this->mText;
if ( $this->mEditSectionTokens ) {
$text = preg_replace_callback(
- ParserOutput::EDITSECTION_REGEX,
+ self::EDITSECTION_REGEX,
function ( $m ) {
global $wgOut, $wgLang;
$editsectionPage = Title::newFromText( htmlspecialchars_decode( $m[1] ) );
$text
);
} else {
- $text = preg_replace( ParserOutput::EDITSECTION_REGEX, '', $text );
+ $text = preg_replace( self::EDITSECTION_REGEX, '', $text );
}
// If you have an old cached version of this class - sorry, you can't disable the TOC
* @return string Filtered data, or a comment containing an error message
*/
public static function filter( $filter, $data, array $options = [] ) {
- if ( strpos( $data, ResourceLoader::FILTER_NOMIN ) !== false ) {
+ if ( strpos( $data, self::FILTER_NOMIN ) !== false ) {
return $data;
}
// mw.loader.implement will use globalEval if scripts is a string.
// Minify manually here, because general response minification is
// not effective due it being a string literal, not a function.
- if ( !ResourceLoader::inDebugMode() ) {
+ if ( !self::inDebugMode() ) {
$scripts = self::filter( 'minify-js', $scripts ); // T107377
}
} else {
} else {
if ( count( $states ) ) {
$this->errors[] = 'Problematic modules: ' .
- FormatJson::encode( $states, ResourceLoader::inDebugMode() );
+ FormatJson::encode( $states, self::inDebugMode() );
}
}
];
self::trimArray( $module );
- return Xml::encodeJsCall( 'mw.loader.implement', $module, ResourceLoader::inDebugMode() );
+ return Xml::encodeJsCall( 'mw.loader.implement', $module, self::inDebugMode() );
}
/**
return Xml::encodeJsCall(
'mw.messages.set',
[ (object)$messages ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
}
return Xml::encodeJsCall(
'mw.loader.state',
[ $name ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
} else {
return Xml::encodeJsCall(
'mw.loader.state',
[ $name, $state ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
}
}
return Xml::encodeJsCall(
"( function ( name, version, dependencies, group, source ) {\n\t$script\n} )",
[ $name, $version, $dependencies, $group, $source ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
}
return Xml::encodeJsCall(
'mw.loader.register',
[ $name ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
} else {
$registration = [ $name, $version, $dependencies, $group, $source, $skip ];
return Xml::encodeJsCall(
'mw.loader.register',
$registration,
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
}
}
return Xml::encodeJsCall(
'mw.loader.addSource',
[ $id ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
} else {
return Xml::encodeJsCall(
'mw.loader.addSource',
[ $id, $loadUrl ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
}
}
return Xml::encodeJsCall(
'mw.config.set',
[ $configuration ],
- ResourceLoader::inDebugMode()
+ self::inDebugMode()
);
}
static function normalizeKey( $key ) {
global $wgDefaultSkin, $wgFallbackSkin;
- $skinNames = Skin::getSkinNames();
+ $skinNames = self::getSkinNames();
// Make keys lowercase for case-insensitive matching.
$skinNames = array_change_key_case( $skinNames, CASE_LOWER );
return true;
} elseif ( $securityStatus === AuthManager::SEC_REAUTH ) {
$request = $this->getRequest();
- $title = SpecialPage::getTitleFor( 'Userlogin' );
+ $title = self::getTitleFor( 'Userlogin' );
$query = [
'returnto' => $this->getFullTitle()->getPrefixedDBkey(),
'returntoquery' => wfArrayToCgi( array_diff_key( $request->getQueryValues(),
if (
$this->allowComments &&
!( $this->inRCDATA || $this->inRAWTEXT ) &&
- preg_match( Balancer::VALID_COMMENT_REGEX, $x, $regs, PREG_OFFSET_CAPTURE ) &&
+ preg_match( self::VALID_COMMENT_REGEX, $x, $regs, PREG_OFFSET_CAPTURE ) &&
// verify EOF condition where necessary
( $regs[4][1] < 0 || !$this->bitsIterator->valid() )
) {
* @return array|false
*/
public static function canonicalizeLoginData( $username, $password ) {
- $sep = BotPassword::getSeparator();
+ $sep = self::getSeparator();
// the strlen check helps minimize the password information obtainable from timing
if ( strlen( $password ) >= 32 && strpos( $username, $sep ) !== false ) {
// the separator is not valid in new usernames but might appear in legacy ones
]
);
- return $id ? User::newFromId( $id ) : null;
+ return $id ? self::newFromId( $id ) : null;
}
/**
global $wgContLang, $wgMaxNameChars;
if ( $name == ''
- || User::isIP( $name )
+ || self::isIP( $name )
|| strpos( $name, '/' ) !== false
|| strlen( $name ) > $wgMaxNameChars
|| $name != $wgContLang->ucfirst( $name )
case false:
break;
case 'valid':
- if ( !User::isValidUserName( $name ) ) {
+ if ( !self::isValidUserName( $name ) ) {
$name = false;
}
break;
case 'usable':
- if ( !User::isUsableName( $name ) ) {
+ if ( !self::isUsableName( $name ) ) {
$name = false;
}
break;
case 'creatable':
- if ( !User::isCreatableName( $name ) ) {
+ if ( !self::isCreatableName( $name ) ) {
$name = false;
}
break;
// since extensions may change the set of searchable namespaces depending
// on user groups/permissions.
foreach ( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) {
- $defOpt['searchNs' . $nsnum] = (boolean)$val;
+ $defOpt['searchNs' . $nsnum] = (bool)$val;
}
$defOpt['skin'] = Skin::normalizeKey( $wgDefaultSkin );
* @return int The user's ID; 0 if the user is anonymous or nonexistent
*/
public function getId() {
- if ( $this->mId === null && $this->mName !== null && User::isIP( $this->mName ) ) {
+ if ( $this->mId === null && $this->mName !== null && self::isIP( $this->mName ) ) {
// Special case, we know the user is anonymous
return 0;
} elseif ( !$this->isItemLoaded( 'id' ) ) {
}
$dbw->insert( 'user', $fields, __METHOD__, [ 'IGNORE' ] );
if ( $dbw->affectedRows() ) {
- $newUser = User::newFromId( $dbw->insertId() );
+ $newUser = self::newFromId( $dbw->insertId() );
} else {
$newUser = null;
}
// Do nothing
} elseif ( $wgGroupsAddToSelf[$group] === true ) {
// No idea WHY this would be used, but it's there
- $groups['add-self'] = User::getAllGroups();
+ $groups['add-self'] = self::getAllGroups();
} elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) {
$groups['add-self'] = $wgGroupsAddToSelf[$group];
}
if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
// Do nothing
} elseif ( $wgGroupsRemoveFromSelf[$group] === true ) {
- $groups['remove-self'] = User::getAllGroups();
+ $groups['remove-self'] = self::getAllGroups();
} elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
$groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
}
// compatibility with old "userrights lets you change
// everything")
// Using array_merge to make the groups reindexed
- $all = array_merge( User::getAllGroups() );
+ $all = array_merge( self::getAllGroups() );
return [
'add' => $all,
'remove' => $all,
global $wgLang;
$groups = [];
- foreach ( User::getGroupsWithPermission( $permission ) as $group ) {
+ foreach ( self::getGroupsWithPermission( $permission ) as $group ) {
$groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' );
}
* @return Language
*/
protected static function newFromCode( $code, $fallback = false ) {
- if ( !Language::isValidCode( $code ) ) {
+ if ( !self::isValidCode( $code ) ) {
throw new MWException( "Invalid language code \"$code\"" );
}
- if ( !Language::isValidBuiltInCode( $code ) ) {
+ if ( !self::isValidBuiltInCode( $code ) ) {
// It's not possible to customise this code with class files, so
// just return a Language object. This is to support uselang= hacks.
$lang = new Language;
}
// Keep trying the fallback list until we find an existing class
- $fallbacks = Language::getFallbacksFor( $code );
+ $fallbacks = self::getFallbacksFor( $code );
foreach ( $fallbacks as $fallbackCode ) {
- if ( !Language::isValidBuiltInCode( $fallbackCode ) ) {
+ if ( !self::isValidBuiltInCode( $fallbackCode ) ) {
throw new MWException( "Invalid fallback '$fallbackCode' in fallback sequence for '$code'" );
}
global $wgExtraLanguageNames, $wgUsePigLatinVariant;
// If passed an invalid language code to use, fallback to en
- if ( $inLanguage !== null && !Language::isValidCode( $inLanguage ) ) {
+ if ( $inLanguage !== null && !self::isValidCode( $inLanguage ) ) {
$inLanguage = 'en';
}
case 'D':
$usedDay = true;
$s .= $this->getWeekdayAbbreviation(
- Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1
+ self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1
);
break;
case 'j':
case 'l':
$usedDay = true;
$s .= $this->getWeekdayName(
- Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1
+ self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'w' ) + 1
);
break;
case 'F':
case 'O':
case 'P':
case 'T':
- $s .= Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $s .= self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case 'w':
case 'N':
case 'z':
$usedDay = true;
- $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case 'W':
$usedWeek = true;
- $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case 't':
$usedMonth = true;
- $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case 'L':
$usedIsLeapYear = true;
- $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case 'o':
$usedISOYear = true;
- $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case 'U':
$usedSecond = true;
// fall through
case 'I':
case 'Z':
- $num = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
+ $num = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, $code );
break;
case '\\':
# Backslash escaping
$s .= $num;
$raw = false;
} elseif ( $roman ) {
- $s .= Language::romanNumeral( $num );
+ $s .= self::romanNumeral( $num );
$roman = false;
} elseif ( $hebrewNum ) {
$s .= self::hebrewNumeral( $num );
substr( $ts, 10, 2 ) * 60 - substr( $ts, 12, 2 );
if ( $usedWeek ) {
$possibleTtls[] =
- ( 7 - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400 +
+ ( 7 - self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400 +
$timeRemainingInDay;
} elseif ( $usedISOYear ) {
// December 28th falls on the last ISO week of the year, every year.
substr( $ts, 0, 4 ) . '1228',
$zone ?: new DateTimeZone( 'UTC' )
)->format( 'W' );
- $currentISOWeek = Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'W' );
+ $currentISOWeek = self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'W' );
$weeksRemaining = $lastWeekOfISOYear - $currentISOWeek;
$timeRemainingInWeek =
- ( 7 - Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400
+ ( 7 - self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'N' ) ) * 86400
+ $timeRemainingInDay;
$possibleTtls[] = $weeksRemaining * 604800 + $timeRemainingInWeek;
}
if ( $usedMonth ) {
$possibleTtls[] =
- ( Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 't' ) -
+ ( self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 't' ) -
substr( $ts, 6, 2 ) ) * 86400
+ $timeRemainingInDay;
} elseif ( $usedYear ) {
$possibleTtls[] =
- ( Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 -
- Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400
+ ( self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 -
+ self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400
+ $timeRemainingInDay;
} elseif ( $usedIsLeapYear ) {
$year = substr( $ts, 0, 4 );
$timeRemainingInYear =
- ( Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 -
- Language::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400
+ ( self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'L' ) + 364 -
+ self::dateTimeObjFormat( $dateTimeObj, $ts, $zone, 'z' ) ) * 86400
+ $timeRemainingInDay;
$mod = $year % 4;
if ( $mod || ( !( $year % 100 ) && $year % 400 ) ) {
* @return string Text, wrapped in LRE...PDF or RLE...PDF or nothing
*/
public function embedBidi( $text = '' ) {
- $dir = Language::strongDirFromContent( $text );
+ $dir = self::strongDirFromContent( $text );
if ( $dir === 'ltr' ) {
// Wrap in LEFT-TO-RIGHT EMBEDDING ... POP DIRECTIONAL FORMATTING
return self::$lre . $text . self::$pdf;
$this->mParentLanguage = null;
return null;
}
- $lang = Language::factory( $code );
+ $lang = self::factory( $code );
if ( !$lang->hasVariant( $this->getCode() ) ) {
$this->mParentLanguage = null;
return null;
* @return array Non-empty array, ending in "en"
*/
public static function getFallbacksFor( $code ) {
- if ( $code === 'en' || !Language::isValidBuiltInCode( $code ) ) {
+ if ( $code === 'en' || !self::isValidBuiltInCode( $code ) ) {
return [];
}
// For unknown languages, fallbackSequence returns an empty array,
*/
public function getCompiledPluralRules() {
$pluralRules = self::$dataCache->getItem( strtolower( $this->mCode ), 'compiledPluralRules' );
- $fallbacks = Language::getFallbacksFor( $this->mCode );
+ $fallbacks = self::getFallbacksFor( $this->mCode );
if ( !$pluralRules ) {
foreach ( $fallbacks as $fallbackCode ) {
$pluralRules = self::$dataCache->getItem( strtolower( $fallbackCode ), 'compiledPluralRules' );
*/
public function getPluralRules() {
$pluralRules = self::$dataCache->getItem( strtolower( $this->mCode ), 'pluralRules' );
- $fallbacks = Language::getFallbacksFor( $this->mCode );
+ $fallbacks = self::getFallbacksFor( $this->mCode );
if ( !$pluralRules ) {
foreach ( $fallbacks as $fallbackCode ) {
$pluralRules = self::$dataCache->getItem( strtolower( $fallbackCode ), 'pluralRules' );
*/
public function getPluralRuleTypes() {
$pluralRuleTypes = self::$dataCache->getItem( strtolower( $this->mCode ), 'pluralRuleTypes' );
- $fallbacks = Language::getFallbacksFor( $this->mCode );
+ $fallbacks = self::getFallbacksFor( $this->mCode );
if ( !$pluralRuleTypes ) {
foreach ( $fallbacks as $fallbackCode ) {
$pluralRuleTypes = self::$dataCache->getItem( strtolower( $fallbackCode ), 'pluralRuleTypes' );
* @return mixed
*/
protected function getStdin( $len = null ) {
- if ( $len == Maintenance::STDIN_ALL ) {
+ if ( $len == self::STDIN_ALL ) {
return file_get_contents( 'php://stdin' );
}
$f = fopen( 'php://stdin', 'rt' );
* @return int
*/
public function getDbType() {
- return Maintenance::DB_STD;
+ return self::DB_STD;
}
/**
* @return bool True if no error or error string in case of errors
*/
public static function checkSqlSyntax( $files ) {
- if ( !Sqlite::isPresent() ) {
+ if ( !self::isPresent() ) {
throw new MWException( "Can't check SQL syntax: SQLite not found" );
}
if ( !is_array( $files ) ) {
*/
function __construct( $opts, $args ) {
if ( !$this->checkOpts( $opts, $args ) ) {
- UserOptions::showUsageAndExit();
+ self::showUsageAndExit();
} else {
$this->mReady = $this->initializeOpts( $opts, $args );
}
<arg name="bootstrap" value="vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/>
<arg name="encoding" value="UTF-8"/>
<arg name="extensions" value="php,php5,inc,sample"/>
- <exclude-pattern>node_modules/</exclude-pattern>
- <exclude-pattern>vendor/</exclude-pattern>
<exclude-pattern type="relative">^extensions/</exclude-pattern>
<exclude-pattern type="relative">^skins/</exclude-pattern>
- <exclude-pattern>\.git</exclude-pattern>
<exclude-pattern>AdminSettings\.php</exclude-pattern>
<exclude-pattern>LocalSettings\.php</exclude-pattern>
<exclude-pattern>StartProfiler\.php</exclude-pattern>
global $wgParserTestFiles;
// Add core test files
- $files = array_map( function( $item ) {
+ $files = array_map( function ( $item ) {
return __DIR__ . "/$item";
}, self::$coreTestFiles );
global $wgDummyLazy;
$called = false;
- $factory = function() use ( &$called ) {
+ $factory = function () use ( &$called ) {
$called = true;
return new HashBagOStuff();
};
->method( 'getConfig' )
->willReturn( $configMock );
- $this->setTemporaryHook( 'PreferencesFormPreSave', function(
+ $this->setTemporaryHook( 'PreferencesFormPreSave', function (
$formData, $form, $user, &$result, $oldUserOptions )
use ( $newOptions, $oldOptions, $userMock ) {
-
$this->assertSame( $userMock, $user );
foreach ( $newOptions as $option => $value ) {
$this->assertSame( $value, $formData[ $option ] );
public static function dataGetSection() {
return [
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"0",
"Intro"
],
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"2",
"== test ==
just a test"
],
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"8",
false
],
public static function dataReplaceSection() {
return [
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"0",
"No more",
null,
- trim( preg_replace( '/^Intro/sm', 'No more', WikitextContentTest::$sections ) )
+ trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
],
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"",
"No more",
null,
"No more"
],
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"2",
"== TEST ==\nmore fun",
null,
trim( preg_replace(
'/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==",
- WikitextContentTest::$sections
+ self::$sections
) )
],
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"8",
"No more",
null,
- WikitextContentTest::$sections
+ self::$sections
],
- [ WikitextContentTest::$sections,
+ [ self::$sections,
"new",
"No more",
"New",
- trim( WikitextContentTest::$sections ) . "\n\n\n== New ==\n\nNo more"
+ trim( self::$sections ) . "\n\n\n== New ==\n\nNo more"
],
];
}
return [
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"0",
"No more",
null,
- trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
+ trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"",
"No more",
null,
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"2",
"== TEST ==\nmore fun",
null,
trim( preg_replace( '/^== test ==.*== foo ==/sm',
"== TEST ==\nmore fun\n\n== foo ==",
- WikiPageTest::$sections ) )
+ self::$sections ) )
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"8",
"No more",
null,
- trim( WikiPageTest::$sections )
+ trim( self::$sections )
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"new",
"No more",
"New",
- trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
+ trim( self::$sections ) . "\n\n== New ==\n\nNo more"
],
];
}
public static function insertIntoDb() {
$sitesTable = \MediaWiki\MediaWikiServices::getInstance()->getSiteStore();
$sitesTable->clear();
- $sitesTable->saveSites( TestSites::getSites() );
+ $sitesTable->saveSites( self::getSites() );
}
}