return false;
}
- $mcvalue = ObjectCache::getMainWANInstance()->get( $mckey );
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $mcvalue = $cache->get( $mckey );
if ( $mcvalue ) {
# Check to see if the value has been invalidated
if ( $touched <= $mcvalue['timestamp'] ) {
* @return bool
*/
function storeInMemcached( $mckey, $expiry = 86400 ) {
- ObjectCache::getMainWANInstance()->set( $mckey,
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $cache->set( $mckey,
[
'timestamp' => wfTimestampNow(),
'value' => $this->mText
- ], $expiry
+ ],
+ $expiry
);
return true;
* @file
* @ingroup Feed
*/
+use MediaWiki\MediaWikiServices;
/**
* Helper functions for feeds
$purge = $wgRequest->getVal( 'action' ) === 'purge';
// Allow users with 'purge' right to clear feed caches
if ( $purge && $wgUser->isAllowed( 'purge' ) ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cache->delete( $timekey, 1 );
$cache->delete( $key, 1 );
}
$attribs["xmlns:$tag"] = $ns;
}
} else { // HTML5
- // DOCTYPE
$ret .= "<!DOCTYPE html>\n";
}
$dbr = wfGetDB( DB_MASTER );
$rows = $loadRestrictionsFromDb( $dbr );
} else {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$rows = $cache->getWithSetCallback(
// Page protections always leave a new null revision
$cache->makeKey( 'page-restrictions', $id, $this->getLatestRevID() ),
$fauxReqArr['wlallrev'] = '';
}
- // Create the request
$fauxReq = new FauxRequest( $fauxReqArr );
- // Execute
$module = new ApiMain( $fauxReq );
$module->execute();
$this->setupExternalResponse( $module, $params );
}
- // Execute
$module->execute();
Hooks::run( 'APIAfterExecute', [ &$module ] );
$this->reportUnusedParams();
if ( !$this->mInternalMode ) {
- // append Debug information
MWDebug::appendDebugInfoToApiResult( $this->getContext(), $this->getResult() );
- // Print result data
$this->printResult();
}
}
}
} elseif ( $modCacheMode === 'public' ) {
// do nothing, if it's public already it will stay public
- } else { // private
+ } else {
$cacheMode = 'private';
}
*/
use Wikimedia\Rdbms\ResultWrapper;
+use MediaWiki\MediaWikiServices;
/**
* Feed to Special:RecentChanges and Special:RecentChangesLiked
return null;
}
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$optionsHash = md5( serialize( $opts->getAllValues() ) ) . $wgRenderHashAppend;
$timekey = $cache->makeKey(
$this->type, $this->format, $wgLang->getCode(), $optionsHash, 'timestamp' );
* @param string $key Memcached key of the content
*/
public function saveToCache( $feed, $timekey, $key ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cache->set( $key, $feed, $cache::TTL_DAY );
$cache->set( $timekey, wfTimestamp( TS_MW ), $cache::TTL_DAY );
}
public function loadFromCache( $lastmod, $timekey, $key ) {
global $wgFeedCacheTimeout, $wgOut;
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$feedLastmod = $cache->get( $timekey );
if ( ( $wgFeedCacheTimeout > 0 ) && $feedLastmod ) {
$loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
// User links and action text
$action = $formatter->getActionText();
- // Comment
+
$comment = $this->list->getLanguage()->getDirMark() .
$formatter->getComment();
}
if ( $this->readState == 'status' ) {
$this->processStatusLine( $lines[0] );
- } else { // header
+ } else {
$this->processHeaderLine( $lines[0] );
}
$this->readBuffer = $lines[1];
private function unserialize( $string ) {
if ( $this->encoding === 'YAML' ) {
return yaml_parse( $string );
- } else { // JSON
+ } else {
return json_decode( $string, true );
}
}
<?php
+use MediaWiki\MediaWikiServices;
use MediaWiki\Linker\LinkTarget;
use Psr\Log\LoggerInterface;
use Wikimedia\Rdbms\IDatabase;
function doUpdate() {
$reaper = new WANObjectCacheReaper(
- ObjectCache::getMainWANInstance(),
+ MediaWikiServices::getInstance()->getMainWANObjectCache(),
ObjectCache::getLocalClusterInstance(),
[ $this, 'getTitleChangeEvents' ],
[ $this, 'getEventAffectedKeys' ],
// Cacheable?
$key = false;
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
if ( $this->mOldid && $this->mNewid ) {
// Check if subclass is still using the old way
// for backwards-compatibility
parent::__construct( $params );
$this->cluster = $params['cluster'] ?? false;
- $this->cache = ObjectCache::getMainWANInstance();
+ $this->cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
}
protected function supportedOrders() {
$this->stats->increment( "wanobjectcache.$kClass.hit.good" );
return $value;
- } elseif ( $this->asyncHandler ) {
- // Update the cache value later, such during post-send of an HTTP request
- $func = $this->asyncHandler;
- $func( function () use ( $key, $ttl, $callback, $opts, $asOf ) {
- $opts['minAsOf'] = INF; // force a refresh
- $this->doGetWithSetCallback( $key, $ttl, $callback, $opts, $asOf );
- } );
+ } elseif ( $this->scheduleAsyncRefresh( $key, $ttl, $callback, $opts ) ) {
$this->stats->increment( "wanobjectcache.$kClass.hit.refresh" );
return $value;
return $ok;
}
+ /**
+ * @param string $key
+ * @param int $ttl
+ * @param callable $callback
+ * @param array $opts
+ * @return bool Success
+ */
+ private function scheduleAsyncRefresh( $key, $ttl, $callback, $opts ) {
+ if ( !$this->asyncHandler ) {
+ return false;
+ }
+ // Update the cache value later, such during post-send of an HTTP request
+ $func = $this->asyncHandler;
+ $func( function () use ( $key, $ttl, $callback, $opts ) {
+ $asOf = null; // unused
+ $opts['minAsOf'] = INF; // force a refresh
+ $this->doGetWithSetCallback( $key, $ttl, $callback, $opts, $asOf );
+ } );
+
+ return true;
+ }
+
/**
* Check if a key is fresh or in the grace window and thus due for randomized reuse
*
* @file
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
/**
* Handler for DjVu images
}
protected function getDimensionInfo( File $file ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$cache->makeKey( 'file-djvu', 'dimensions', $file->getSha1() ),
$cache::TTL_INDEFINITE,
$val = substr( $this->mFilteredExifData[$prop], 8 );
switch ( $charCode ) {
- case "\x4A\x49\x53\x00\x00\x00\x00\x00":
- // JIS
+ case "JIS\x00\x00\x00\x00\x00":
$charset = "Shift-JIS";
break;
case "UNICODE\x00":
*/
public function getContentModel() {
if ( $this->exists() ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$cache->makeKey( 'page-content-model', $this->getLatest() ),
$username = trim( $username );
- // default
$gender = User::getDefaultOption( 'gender' );
// allow prefix and normalize (e.g. "*foo" -> "*foo" ).
];
}
- // Language
$languages = Language::fetchLanguageNames( null, 'mwfile' );
$languageCode = $this->config->get( 'LanguageCode' );
if ( !array_key_exists( $languageCode, $languages ) ) {
$option = [ 'default' => $option ];
}
foreach ( $option as $skin => $data ) {
- if ( !is_array( $option ) ) {
+ if ( !is_array( $data ) ) {
throw new InvalidArgumentException(
- "Invalid list error. '$option' given, array expected."
+ "Invalid list error. '$data' given, array expected."
);
}
}
}
$content['scripts'] = $scripts;
- // Styles
$styles = [];
// Don't create empty stylesheets like [ '' => '' ] for modules
// that don't *have* any stylesheets (T40024).
if ( !$this->getConfig()->get( 'ResourceLoaderValidateJS' ) ) {
return $contents;
}
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$cache->makeGlobalKey(
'resourceloader',
use Wikimedia\Assert\Assert;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\MediaWikiServices;
/**
* Abstraction for ResourceLoader modules which pull from wiki pages
$func = [ static::class, 'fetchTitleInfo' ];
$fname = __METHOD__;
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$allInfo = $cache->getWithSetCallback(
$cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getDomainID(), $hash ),
$cache::TTL_HOUR,
}
if ( $purge ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$key = $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $domain );
$cache->touchCheckKey( $key );
}
$loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
// User links and action text
$action = $formatter->getActionText();
- // Comment
+
$comment = CommentStore::getStore()->getComment( 'log_comment', $this->row )->text;
$comment = $this->list->getLanguage()->getDirMark()
. Linker::commentBlock( $comment );
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\MediaWikiServices;
/**
* Special page which uses a ChangesList to show query results.
* @return array Tag data
*/
protected static function getChangeTagList( ResourceLoaderContext $context ) {
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage() ),
$cache::TTL_MINUTE * 10,
}
protected function setup( $par ) {
- // Options
$opts = new FormOptions();
$this->opts = $opts; // bind
$opts->add( 'hideliu', false );
$opts->add( $key, $params['default'] );
}
- // Set values
$opts->fetchValuesFromRequest( $this->getRequest() );
if ( $par ) {
$this->parseParams( $par );
}
- // Validate
$opts->validateIntBounds( 'limit', 0, 5000 );
}
// add raw $hitcount for sorting, because tags-hitcount contains numbers and letters
$newRow .= Xml::tags( 'td', [ 'data-sort-value' => $hitcount ], $hitcountLabel );
- // actions
$actionLinks = [];
- // delete
if ( $showDeleteActions && ChangeTags::canDeleteTag( $tag )->isOK() ) {
$actionLinks[] = $linkRenderer->makeKnownLink(
$this->getPageTitle( 'delete' ),
}
if ( $showManageActions ) { // we've already checked that the user had the requisite userright
- // activate
if ( ChangeTags::canActivateTag( $tag )->isOK() ) {
$actionLinks[] = $linkRenderer->makeKnownLink(
$this->getPageTitle( 'activate' ),
[ 'tag' => $tag ] );
}
- // deactivate
if ( ChangeTags::canDeactivateTag( $tag )->isOK() ) {
$actionLinks[] = $linkRenderer->makeKnownLink(
$this->getPageTitle( 'deactivate' ),
return Status::newFatal( 'botpasswords-locked' );
}
- // Throttle
$throttle = null;
if ( !empty( $wgPasswordAttemptThrottle ) ) {
$throttle = new MediaWiki\Auth\Throttler( $wgPasswordAttemptThrottle, [
'src' => $fsFile->getPath(), 'dst' => $dPath, 'overwrite' => 1 ];
} elseif ( $sExists === false ) { // does not exist in source
$ops[] = [ 'op' => 'delete', 'src' => $dPath, 'ignoreMissingSource' => 1 ];
- } else { // error
+ } else {
$this->error( "Unable to sync '$dPath': could not stat file." );
$status->fatal( 'backend-fail-internal', $src->getName() );
'group' => 'jquery.ui',
'targets' => [ 'desktop', 'mobile' ],
],
- // Effects
+
'jquery.effects.core' => [
'deprecated' => true,
'scripts' => 'resources/lib/jquery.ui/jquery.ui.effect.js',
padding-right: 1.875em + 0.5em;
> .oo-ui-buttonWidget {
- top: 50%;
- .transform( translateY( -50% ) );
+ top: 0.5em;
}
> .oo-ui-iconWidget {
- float: none;
- display: inline-block;
- margin: 0;
+ vertical-align: top;
}
> .oo-ui-labelElement-label {
float: none;
display: inline-block;
+ // Label doesn't wrap without `max-width`. First setting a pretty arbitrary percentage value.
+ max-width: 80%;
+ // Overwrite it with `calc` reduced by icon width and left margin combined.
+ max-width: calc( ~'100% - 1.42857143em - 0.25em' );
+ margin: 0 0 0 0.25em;
font-size: 1.2em;
- margin: 0;
font-weight: bold;
- vertical-align: middle;
+ line-height: 1.25;
+ vertical-align: top;
}
}
}
$linkRenderer->makeKnownLink( $target, null, [], [ 'foo' => 'bar' ] )
);
- // forcearticlepath
$linkRenderer->setForceArticlePath( true );
$this->assertEquals(
'<a href="/wiki/Foobar?foo=bar" title="Foobar">Foobar</a>',