Add namespace to the root classes of ObjectCache

And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
This commit is contained in:
Ebrahim Byagowi 2024-07-09 17:07:44 +03:30
parent 0985ed781c
commit fab78547ad
165 changed files with 526 additions and 153 deletions

View file

@ -376,6 +376,21 @@ because of Phabricator reports.
- FileBackend
- Wikimedia\Http:
- MultiHttpClient
- Wikimedia\ObjectCache:
- APCUBagOStuff
- BagOStuff
- CachedBagOStuff
- EmptyBagOStuff
- HashBagOStuff
- IStoreKeyEncoder
- MediumSpecificBagOStuff
- MemcachedBagOStuff
- MemcachedPeclBagOStuff
- MemcachedPhpBagOStuff
- MultiWriteBagOStuff
- RESTBagOStuff
- RedisBagOStuff
- WinCacheBagOStuff
* MessageCache::get() with $language other than Language or null is
deprecated and emits deprecation warnings. For high-level access,
use wfMessage() or RequestContext::msg() instead.

View file

@ -3235,6 +3235,20 @@ $wgAutoloadLocalClasses = [
'Wikimedia\\Mime\\MimeMap' => __DIR__ . '/includes/libs/mime/MimeMap.php',
'Wikimedia\\Mime\\MimeMapMinimal' => __DIR__ . '/includes/libs/mime/MimeMapMinimal.php',
'Wikimedia\\NonSerializable\\NonSerializableTrait' => __DIR__ . '/includes/libs/NonSerializableTrait.php',
'Wikimedia\\ObjectCache\\APCUBagOStuff' => __DIR__ . '/includes/libs/objectcache/APCUBagOStuff.php',
'Wikimedia\\ObjectCache\\BagOStuff' => __DIR__ . '/includes/libs/objectcache/BagOStuff.php',
'Wikimedia\\ObjectCache\\CachedBagOStuff' => __DIR__ . '/includes/libs/objectcache/CachedBagOStuff.php',
'Wikimedia\\ObjectCache\\EmptyBagOStuff' => __DIR__ . '/includes/libs/objectcache/EmptyBagOStuff.php',
'Wikimedia\\ObjectCache\\HashBagOStuff' => __DIR__ . '/includes/libs/objectcache/HashBagOStuff.php',
'Wikimedia\\ObjectCache\\IStoreKeyEncoder' => __DIR__ . '/includes/libs/objectcache/IStoreKeyEncoder.php',
'Wikimedia\\ObjectCache\\MediumSpecificBagOStuff' => __DIR__ . '/includes/libs/objectcache/MediumSpecificBagOStuff.php',
'Wikimedia\\ObjectCache\\MemcachedBagOStuff' => __DIR__ . '/includes/libs/objectcache/MemcachedBagOStuff.php',
'Wikimedia\\ObjectCache\\MemcachedPeclBagOStuff' => __DIR__ . '/includes/libs/objectcache/MemcachedPeclBagOStuff.php',
'Wikimedia\\ObjectCache\\MemcachedPhpBagOStuff' => __DIR__ . '/includes/libs/objectcache/MemcachedPhpBagOStuff.php',
'Wikimedia\\ObjectCache\\MultiWriteBagOStuff' => __DIR__ . '/includes/libs/objectcache/MultiWriteBagOStuff.php',
'Wikimedia\\ObjectCache\\RESTBagOStuff' => __DIR__ . '/includes/libs/objectcache/RESTBagOStuff.php',
'Wikimedia\\ObjectCache\\RedisBagOStuff' => __DIR__ . '/includes/libs/objectcache/RedisBagOStuff.php',
'Wikimedia\\ObjectCache\\WinCacheBagOStuff' => __DIR__ . '/includes/libs/objectcache/WinCacheBagOStuff.php',
'Wikimedia\\ParamValidator\\Callbacks' => __DIR__ . '/includes/libs/ParamValidator/Callbacks.php',
'Wikimedia\\ParamValidator\\ParamValidator' => __DIR__ . '/includes/libs/ParamValidator/ParamValidator.php',
'Wikimedia\\ParamValidator\\SimpleCallbacks' => __DIR__ . '/includes/libs/ParamValidator/SimpleCallbacks.php',

View file

@ -2387,14 +2387,14 @@ config-schema:
@since 1.20
ObjectCaches:
default:
0: { class: EmptyBagOStuff, reportDupes: false }
0: { class: Wikimedia\ObjectCache\EmptyBagOStuff, reportDupes: false }
1: { class: SqlBagOStuff, loggroup: SQLBagOStuff }
memcached-php: { class: MemcachedPhpBagOStuff, loggroup: memcached }
memcached-pecl: { class: MemcachedPeclBagOStuff, loggroup: memcached }
hash: { class: HashBagOStuff, reportDupes: false }
apc: { class: APCUBagOStuff, reportDupes: false }
apcu: { class: APCUBagOStuff, reportDupes: false }
wincache: { class: WinCacheBagOStuff, reportDupes: false }
memcached-php: { class: Wikimedia\ObjectCache\MemcachedPhpBagOStuff, loggroup: memcached }
memcached-pecl: { class: Wikimedia\ObjectCache\MemcachedPeclBagOStuff, loggroup: memcached }
hash: { class: Wikimedia\ObjectCache\HashBagOStuff, reportDupes: false }
apc: { class: Wikimedia\ObjectCache\APCUBagOStuff, reportDupes: false }
apcu: { class: Wikimedia\ObjectCache\APCUBagOStuff, reportDupes: false }
wincache: { class: Wikimedia\ObjectCache\WinCacheBagOStuff, reportDupes: false }
type: object
description: |-
Advanced object cache configuration.
@ -2446,7 +2446,7 @@ config-schema:
operations that can be chunked into a set of smaller writes.
For MemcachedPhpBagOStuff parameters see {@link MemcachedPhpBagOStuff::__construct}
For MemcachedPeclBagOStuff parameters see {@link MemcachedPeclBagOStuff::__construct}
For RedisBagOStuff parameters see {@link RedisBagOStuff::__construct}
For RedisBagOStuff parameters see {@link Wikimedia\ObjectCache\RedisBagOStuff::__construct}
WANObjectCache:
default: { }
type: object
@ -2472,7 +2472,7 @@ config-schema:
2.) it should be evicted ONLY after the TTL elapses (reliably persist),
3.) should be accessed by all servers that serve the application,
4.) should be able to handle a high volume of writes and reads.
@see \BagOStuff
@see \Wikimedia\ObjectCache\BagOStuff
@since 1.42
MainStash:
default: 1
@ -2495,7 +2495,7 @@ config-schema:
and violations of linearizability (e.g. during timeouts). Modules that can never handle
these kinds of anomalies should use other storage mediums.
Valid options are the keys of {@link $wgObjectCaches}, e.g. CACHE_* constants.
@see \BagOStuff
@see \Wikimedia\ObjectCache\BagOStuff
@since 1.26
ParsoidCacheConfig:
type: object

View file

@ -2,13 +2,13 @@
namespace MediaWiki\Html;
use BagOStuff;
use FileContentsHasher;
use LightnCandy\LightnCandy;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use RuntimeException;
use UnexpectedValueException;
use Wikimedia\ObjectCache\BagOStuff;
/**
* Handles compiling Mustache templates into PHP rendering functions

View file

@ -11,7 +11,6 @@
// phpcs:disable Generic.Files.LineLength.TooLong
namespace MediaWiki;
use APCUBagOStuff;
use AssembleUploadChunksJob;
use BlockLogFormatter;
use CategoryMembershipChangeJob;
@ -24,10 +23,8 @@ use DeleteLogFormatter;
use DeletePageJob;
use DoubleRedirectJob;
use EmaillingJob;
use EmptyBagOStuff;
use EnotifNotifyJob;
use Generator;
use HashBagOStuff;
use HTMLCacheUpdateJob;
use ImportLogFormatter;
use InvalidArgumentException;
@ -71,8 +68,6 @@ use MediaWiki\Watchlist\ActivityUpdateJob;
use MediaWiki\Watchlist\ClearUserWatchlistJob;
use MediaWiki\Watchlist\ClearWatchlistNotificationsJob;
use MediaWiki\Watchlist\WatchlistExpiryJob;
use MemcachedPeclBagOStuff;
use MemcachedPhpBagOStuff;
use MergeLogFormatter;
use MoveLogFormatter;
use NullJob;
@ -95,8 +90,13 @@ use UserEditCountInitJob;
use UserGroupExpiryJob;
use UserOptionsUpdateJob;
use Wikimedia\EventRelayer\EventRelayerNull;
use Wikimedia\ObjectCache\APCUBagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ObjectCache\MemcachedPeclBagOStuff;
use Wikimedia\ObjectCache\MemcachedPhpBagOStuff;
use Wikimedia\ObjectCache\WinCacheBagOStuff;
use WikitextContentHandler;
use WinCacheBagOStuff;
/**
* This class contains schema declarations for all configuration variables
@ -3953,7 +3953,7 @@ class MainConfigSchema {
*
* For MemcachedPeclBagOStuff parameters see {@link MemcachedPeclBagOStuff::__construct}
*
* For RedisBagOStuff parameters see {@link RedisBagOStuff::__construct}
* For RedisBagOStuff parameters see {@link Wikimedia\ObjectCache\RedisBagOStuff::__construct}
*/
public const ObjectCaches = [
'default' => [
@ -4010,7 +4010,7 @@ class MainConfigSchema {
* 3.) should be accessed by all servers that serve the application,
* 4.) should be able to handle a high volume of writes and reads.
*
* @see \BagOStuff
* @see \Wikimedia\ObjectCache\BagOStuff
* @since 1.42
*/
public const MicroStashType = [
@ -4042,7 +4042,7 @@ class MainConfigSchema {
*
* Valid options are the keys of {@link $wgObjectCaches}, e.g. CACHE_* constants.
*
* @see \BagOStuff
* @see \Wikimedia\ObjectCache\BagOStuff
* @since 1.26
*/
public const MainStash = [

View file

@ -20,7 +20,6 @@
namespace MediaWiki;
use BagOStuff;
use CryptHKDF;
use DateFormatterFactory;
use ExtensionRegistry;
@ -207,6 +206,7 @@ use WikiImporterFactory;
use Wikimedia\EventRelayer\EventRelayerGroup;
use Wikimedia\Message\IMessageFormatterFactory;
use Wikimedia\NonSerializable\NonSerializableTrait;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
use Wikimedia\Parsoid\Config\DataAccess;
use Wikimedia\Rdbms\ChronologyProtector;

View file

@ -22,6 +22,7 @@
# T32219 : can not use pathinfo() on URLs since slashes do not match
use MediaWiki\Html\TemplateParser;
use Wikimedia\ObjectCache\EmptyBagOStuff;
$matches = [];
$path = '/';

View file

@ -22,10 +22,8 @@
namespace MediaWiki\ResourceLoader;
use BagOStuff;
use Exception;
use ExtensionRegistry;
use HashBagOStuff;
use HttpStatus;
use InvalidArgumentException;
use Less_Environment;
@ -66,6 +64,8 @@ use Wikimedia\Minify\JavaScriptMapperState;
use Wikimedia\Minify\JavaScriptMinifier;
use Wikimedia\Minify\JavaScriptMinifierState;
use Wikimedia\Minify\MinifierState;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\RequestTimeout\TimeoutException;
use Wikimedia\ScopedCallback;
use Wikimedia\Stats\StatsFactory;

View file

@ -20,8 +20,8 @@
namespace Wikimedia\DependencyStore;
use BagOStuff;
use InvalidArgumentException;
use Wikimedia\ObjectCache\BagOStuff;
/**
* Track per-module file dependencies in object cache via BagOStuff.

View file

@ -2,7 +2,6 @@
namespace MediaWiki\Rest;
use BagOStuff;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\MainConfigNames;
@ -18,6 +17,7 @@ use MediaWiki\Rest\Validator\Validator;
use MediaWiki\Session\Session;
use Throwable;
use Wikimedia\Message\MessageValue;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
use Wikimedia\Stats\StatsFactory;

View file

@ -25,7 +25,6 @@
namespace MediaWiki\Revision;
use BagOStuff;
use Content;
use DBAccessObjectUtils;
use IDBAccessObject;
@ -69,6 +68,7 @@ use Traversable;
use WANObjectCache;
use Wikimedia\Assert\Assert;
use Wikimedia\IPUtils;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\ILoadBalancer;

View file

@ -26,7 +26,6 @@
namespace MediaWiki\Revision;
use BagOStuff;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\HookContainer\HookContainer;
@ -39,6 +38,7 @@ use MediaWiki\User\ActorStoreFactory;
use Psr\Log\LoggerInterface;
use WANObjectCache;
use Wikimedia\Assert\Assert;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\ILBFactory;
/**

View file

@ -245,6 +245,9 @@ use Wikimedia\DependencyStore\KeyValueDependencyStore;
use Wikimedia\DependencyStore\SqlModuleDependencyStore;
use Wikimedia\EventRelayer\EventRelayerGroup;
use Wikimedia\Message\IMessageFormatterFactory;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
use Wikimedia\Parsoid\Config\DataAccess;
use Wikimedia\Parsoid\Parsoid;

View file

@ -2,11 +2,11 @@
namespace MediaWiki\Settings\Cache;
use BagOStuff;
use MediaWiki\Settings\SettingsBuilderException;
use MediaWiki\Settings\Source\SettingsIncludeLocator;
use MediaWiki\Settings\Source\SettingsSource;
use Stringable;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\WaitConditionLoop;
/**

View file

@ -2,7 +2,6 @@
namespace MediaWiki\Settings;
use BagOStuff;
use ExtensionRegistry;
use MediaWiki\Config\Config;
use MediaWiki\Config\HashConfig;
@ -23,6 +22,7 @@ use MediaWiki\Settings\Source\SettingsIncludeLocator;
use MediaWiki\Settings\Source\SettingsSource;
use RuntimeException;
use StatusValue;
use Wikimedia\ObjectCache\BagOStuff;
use function array_key_exists;
/**

View file

@ -20,10 +20,10 @@
namespace MediaWiki\Storage;
use BagOStuff;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Json\FormatJson;
use MediaWiki\MainConfigNames;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\IConnectionProvider;
/**

View file

@ -20,7 +20,6 @@
namespace MediaWiki\Storage;
use BagOStuff;
use Content;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
@ -35,6 +34,7 @@ use MediaWiki\User\UserFactory;
use MediaWiki\User\UserIdentity;
use Psr\Log\LoggerInterface;
use stdClass;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\IConnectionProvider;
use Wikimedia\ScopedCallback;
use Wikimedia\Stats\StatsFactory;

View file

@ -21,10 +21,10 @@
namespace MediaWiki\Auth;
use BagOStuff;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\User;
use Wikimedia\ObjectCache\BagOStuff;
/**
* A pre-authentication provider to throttle authentication actions.

View file

@ -21,7 +21,6 @@
namespace MediaWiki\Auth;
use BagOStuff;
use InvalidArgumentException;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MainConfigNames;
@ -29,6 +28,7 @@ use MediaWiki\MediaWikiServices;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Wikimedia\ObjectCache\BagOStuff;
/**
* A helper class for throttling authentication attempts.

View file

@ -23,13 +23,13 @@
namespace MediaWiki\Cache;
use BagOStuff;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Request\WebRequest;
use Wikimedia\AtEase\AtEase;
use Wikimedia\IPUtils;
use Wikimedia\ObjectCache\BagOStuff;
/**
* Base class for data storage in the file system.

View file

@ -464,7 +464,7 @@ return [
'LanguageConverterCacheType' => -1,
'ObjectCaches' => [
0 => [
'class' => 'EmptyBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\EmptyBagOStuff',
'reportDupes' => false,
],
1 => [
@ -472,27 +472,27 @@ return [
'loggroup' => 'SQLBagOStuff',
],
'memcached-php' => [
'class' => 'MemcachedPhpBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\MemcachedPhpBagOStuff',
'loggroup' => 'memcached',
],
'memcached-pecl' => [
'class' => 'MemcachedPeclBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\MemcachedPeclBagOStuff',
'loggroup' => 'memcached',
],
'hash' => [
'class' => 'HashBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\HashBagOStuff',
'reportDupes' => false,
],
'apc' => [
'class' => 'APCUBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\APCUBagOStuff',
'reportDupes' => false,
],
'apcu' => [
'class' => 'APCUBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\APCUBagOStuff',
'reportDupes' => false,
],
'wincache' => [
'class' => 'WinCacheBagOStuff',
'class' => 'Wikimedia\\ObjectCache\\WinCacheBagOStuff',
'reportDupes' => false,
],
],

View file

@ -20,13 +20,13 @@
namespace MediaWiki\Config;
use BagOStuff;
use DnsSrvDiscoverer;
use HashBagOStuff;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Wikimedia\Http\MultiHttpClient;
use Wikimedia\IPUtils;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
use Wikimedia\WaitConditionLoop;

View file

@ -28,6 +28,7 @@ use MediaWiki\Debug\MWDebug;
use MediaWiki\Deferred\DeferredUpdates;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MainConfigNames;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\ChronologyProtector;
use Wikimedia\Rdbms\ConfiguredReadOnlyMode;
use Wikimedia\Rdbms\DatabaseDomain;

View file

@ -2,9 +2,9 @@
namespace MediaWiki\Edit;
use BagOStuff;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Parser\Parsoid\PageBundleJsonTrait;
use Wikimedia\ObjectCache\BagOStuff;
/**
* @internal

View file

@ -23,7 +23,6 @@
namespace MediaWiki\FileBackend;
use BagOStuff;
use FileBackendMultiWrite;
use FSFileBackend;
use InvalidArgumentException;
@ -39,6 +38,7 @@ use MimeAnalyzer;
use Profiler;
use WANObjectCache;
use Wikimedia\FileBackend\FileBackend;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
use Wikimedia\Rdbms\ReadOnlyMode;

View file

@ -27,7 +27,6 @@
namespace MediaWiki\Installer;
use AutoLoader;
use EmptyBagOStuff;
use Exception;
use ExecutableFinder;
use ExtensionDependencyError;
@ -63,6 +62,7 @@ use MWCryptRand;
use ParserOptions;
use RuntimeException;
use Wikimedia\AtEase\AtEase;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\Services\ServiceDisabledException;
use WikitextContent;

View file

@ -20,13 +20,13 @@
namespace MediaWiki\Installer;
use BagOStuff;
use MediaWiki\Config\Config;
use MediaWiki\Http\HttpRequestFactory;
use MediaWiki\Json\FormatJson;
use MediaWiki\MainConfigNames;
use MWCryptRand;
use Psr\Log\LoggerInterface;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\DBError;
use Wikimedia\Rdbms\IConnectionProvider;
use Wikimedia\Timestamp\ConvertibleTimestamp;

View file

@ -18,6 +18,8 @@
* @file
*/
use Wikimedia\ObjectCache\HashBagOStuff;
/**
* PHP memory-backed job queue storage, for testing.
*

View file

@ -38,6 +38,7 @@ use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubUserLang;
use MediaWiki\Title\Title;
use MediaWiki\User\User;
use Wikimedia\ObjectCache\BagOStuff;
/**
* Base class for multi-variant language conversion.

View file

@ -20,8 +20,6 @@
namespace MediaWiki\Languages;
use BagOStuff;
use HashBagOStuff;
use InvalidArgumentException;
use LanguageCode;
use MediaWiki\Config\ServiceOptions;
@ -29,6 +27,8 @@ use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MainConfigNames;
use MediaWiki\Title\MediaWikiTitleCodec;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
/**
* A service that provides utilities to do with language names and codes.

View file

@ -43,6 +43,8 @@ use MediaWiki\Title\Title;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Wikimedia\LightweightObjectStore\ExpirationAwareness;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IExpression;
use Wikimedia\Rdbms\IResultWrapper;

View file

@ -18,6 +18,8 @@
* @file
*/
use Wikimedia\ObjectCache\BagOStuff;
/**
* Store an arbitrary value whilst representing several CacheDependency objects as one.
*

View file

@ -1,4 +1,7 @@
<?php
use Wikimedia\ObjectCache\BagOStuff;
/**
* Extract-and-Expand Key Derivation Function (HKDF). A cryptographically
* secure key expansion function based on RFC 5869.

View file

@ -2,7 +2,7 @@
namespace Wikimedia\WRStats;
use BagOStuff;
use Wikimedia\ObjectCache\BagOStuff;
/**
* An adaptor allowing WRStats to store data in MediaWiki's BagOStuff

View file

@ -24,6 +24,8 @@
use MediaWiki\Json\FormatJson;
use Wikimedia\AtEase\AtEase;
use Wikimedia\FileBackend\FileBackend;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\Timestamp\ConvertibleTimestamp;
/**

View file

@ -28,6 +28,8 @@ use Psr\Log\LoggerInterface;
use Wikimedia\AtEase\AtEase;
use Wikimedia\FileBackend\FileBackend;
use Wikimedia\Http\MultiHttpClient;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\RequestTimeout\TimeoutException;
/**

View file

@ -17,6 +17,9 @@
*
* @file
*/
use Wikimedia\ObjectCache\MemcachedBagOStuff;
use Wikimedia\ObjectCache\MemcachedPhpBagOStuff;
use Wikimedia\WaitConditionLoop;
/**

View file

@ -21,6 +21,8 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
/**
* This is a wrapper for APCu's shared memory functions
*
@ -133,3 +135,6 @@ class APCUBagOStuff extends MediumSpecificBagOStuff {
return $result;
}
}
/** @deprecated class alias since 1.43 */
class_alias( APCUBagOStuff::class, 'APCUBagOStuff' );

View file

@ -26,6 +26,9 @@
* @defgroup Cache Cache
*/
namespace Wikimedia\ObjectCache;
use InvalidArgumentException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
@ -151,13 +154,15 @@ abstract class BagOStuff implements
/**
* @stable to call
*
* @param array $params Parameters include:
* - keyspace: Keyspace to use for keys in makeKey(). [Default: "local"]
* - asyncHandler: Callable to use for scheduling tasks after the web request ends.
* In CLI mode, it should run the task immediately. [Default: null]
* - stats: IStatsdDataFactory instance. [optional]
* - logger: Psr\Log\LoggerInterface instance. [optional]
* @phan-param array{keyspace?:string,logger?:Psr\Log\LoggerInterface,asyncHandler?:callable} $params
* - logger: \Psr\Log\LoggerInterface instance. [optional]
*
* @phan-param array{keyspace?:string,logger?:\Psr\Log\LoggerInterface,asyncHandler?:callable} $params
*/
public function __construct( array $params = [] ) {
$this->keyspace = $params['keyspace'] ?? 'local';
@ -172,6 +177,7 @@ abstract class BagOStuff implements
/**
* @param LoggerInterface $logger
*
* @return void
*/
public function setLogger( LoggerInterface $logger ) {
@ -196,6 +202,7 @@ abstract class BagOStuff implements
* @param int $exptime Time-to-live (seconds)
* @param callable $callback Callback that derives the new value
* @param int $flags Bitfield of BagOStuff::READ_* or BagOStuff::WRITE_* constants [optional]
*
* @return mixed The cached value if found or the result of $callback otherwise
* @since 1.27
*/
@ -223,6 +230,7 @@ abstract class BagOStuff implements
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
*
* @return mixed Returns false on failure or if the item does not exist
*/
abstract public function get( $key, $flags = 0 );
@ -234,6 +242,7 @@ abstract class BagOStuff implements
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
abstract public function set( $key, $value, $exptime = 0, $flags = 0 );
@ -247,6 +256,7 @@ abstract class BagOStuff implements
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success (item deleted or not found)
*/
abstract public function delete( $key, $flags = 0 );
@ -258,6 +268,7 @@ abstract class BagOStuff implements
* @param mixed $value
* @param int $exptime
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success (item created)
*/
abstract public function add( $key, $value, $exptime = 0, $flags = 0 );
@ -276,6 +287,7 @@ abstract class BagOStuff implements
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
* @throws InvalidArgumentException
*/
@ -301,6 +313,7 @@ abstract class BagOStuff implements
* @param string $key
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success (item found and updated)
* @since 1.28
*/
@ -316,6 +329,7 @@ abstract class BagOStuff implements
* using the same value for this parameter, then return true and use reference counting so
* that only the unlock() call from the outermost lock() caller actually releases the lock
* (note that only the outermost time-to-live is used) [optional]
*
* @return bool Success
*/
abstract public function lock( $key, $timeout = 6, $exptime = 6, $rclass = '' );
@ -324,6 +338,7 @@ abstract class BagOStuff implements
* Release an advisory lock on a key string
*
* @param string $key
*
* @return bool Success
*/
abstract public function unlock( $key );
@ -341,6 +356,7 @@ abstract class BagOStuff implements
* @param int $timeout Lock wait timeout; 0 for non-blocking [optional]
* @param int $exptime Lock time-to-live [optional]; 1 day maximum
* @param string $rclass Allow reentry if set and the current lock used this value
*
* @return ScopedCallback|null Returns null on failure
* @since 1.26
*/
@ -366,6 +382,7 @@ abstract class BagOStuff implements
* @param int|float $limit Maximum number of keys to delete [default: INF]
* @param string|null $tag Tag to purge a single shard only.
* This is only supported when server tags are used in configuration.
*
* @return bool Success; false if unimplemented
*/
abstract public function deleteObjectsExpiringBefore(
@ -380,6 +397,7 @@ abstract class BagOStuff implements
*
* @param string[] $keys List of keys
* @param int $flags Bitfield; supports READ_LATEST [optional]
*
* @return mixed[] Map of (key => value) for existing keys
*/
abstract public function getMulti( array $keys, $flags = 0 );
@ -394,6 +412,7 @@ abstract class BagOStuff implements
* @param mixed[] $valueByKey Map of (key => value)
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success
* @since 1.24
*/
@ -408,6 +427,7 @@ abstract class BagOStuff implements
*
* @param string[] $keys List of keys
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success (items deleted and/or not found)
* @since 1.33
*/
@ -421,6 +441,7 @@ abstract class BagOStuff implements
* @param string[] $keys List of keys
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success (all items found and updated)
* @since 1.34
*/
@ -441,6 +462,7 @@ abstract class BagOStuff implements
* @param int $step Amount to increase the key value by [default: 1]
* @param int|null $init Value to initialize the key to if it does not exist [default: $step]
* @param int $flags Bit field of class WRITE_* constants [optional]
*
* @return int|bool New value (or true if asynchronous) on success; false on failure
* @since 1.24
*/
@ -470,6 +492,7 @@ abstract class BagOStuff implements
* - The caller invokes getLastError()
*
* @param int $watchPoint Only consider errors from after this "watch point" [optional]
*
* @return int BagOStuff:ERR_* constant for the "last error" registry
* @note Parameters added in 1.38: $watchPoint
* @since 1.23
@ -492,6 +515,7 @@ abstract class BagOStuff implements
* Set the "last error" registry due to a problem encountered during an attempted operation
*
* @param int $error BagOStuff:ERR_* constant
*
* @since 1.23
*/
protected function setLastError( $error ) {
@ -509,8 +533,10 @@ abstract class BagOStuff implements
*
* @see BagOStuff::makeKeyInternal
* @since 1.27
*
* @param string $keygroup Key group component, should be under 48 characters.
* @param string|int ...$components Additional, ordered, key components for entity IDs
*
* @return string Colon-separated, keyspace-prepended, ordered list of encoded components
*/
public function makeGlobalKey( $keygroup, ...$components ) {
@ -538,8 +564,10 @@ abstract class BagOStuff implements
*
* @see BagOStuff::makeKeyInternal
* @since 1.27
*
* @param string $keygroup Key group component, should be under 48 characters.
* @param string|int ...$components Additional, ordered, key components for entity IDs
*
* @return string Colon-separated, keyspace-prepended, ordered list of encoded components
*/
public function makeKey( $keygroup, ...$components ) {
@ -550,6 +578,7 @@ abstract class BagOStuff implements
* Check whether a cache key is in the global keyspace
*
* @param string $key
*
* @return bool
* @since 1.35
*/
@ -559,6 +588,7 @@ abstract class BagOStuff implements
/**
* @param int $flag BagOStuff::ATTR_* constant
*
* @return int BagOStuff:QOS_* constant
* @since 1.28
*/
@ -573,6 +603,7 @@ abstract class BagOStuff implements
*/
public function getSegmentationSize() {
wfDeprecated( __METHOD__, '1.43' );
return INF;
}
@ -583,12 +614,14 @@ abstract class BagOStuff implements
*/
public function getSegmentedValueMaxSize() {
wfDeprecated( __METHOD__, '1.43' );
return INF;
}
/**
* @param int $field
* @param int $flags
*
* @return bool
* @since 1.34
*/
@ -600,6 +633,7 @@ abstract class BagOStuff implements
* Merge the flag maps of one or more BagOStuff objects into a "lowest common denominator" map
*
* @param BagOStuff[] $bags
*
* @return int[] Resulting flag map (class ATTR_* constant => class QOS_* constant)
*/
final protected function mergeFlagMaps( array $bags ) {
@ -630,8 +664,10 @@ abstract class BagOStuff implements
*
* @see BagOStuff::proxyCall
* @since 1.27
*
* @param string $keyspace
* @param string[]|int[] $components Key group and other components
*
* @return string
*/
protected function makeKeyInternal( $keyspace, $components ) {
@ -644,6 +680,7 @@ abstract class BagOStuff implements
// Escape delimiter (":") and escape ("%") characters
$key .= ':' . strtr( $component, [ '%' => '%25', ':' => '%3A' ] );
}
return $key;
}
@ -664,7 +701,9 @@ abstract class BagOStuff implements
* Convert a key from BagOStuff::makeKeyInternal into one for the current subclass
*
* @see BagOStuff::proxyCall
*
* @param string $key Result from BagOStuff::makeKeyInternal
*
* @return string Result from current subclass override of BagOStuff::makeKeyInternal
*/
private function convertGenericKey( $key ) {
@ -704,6 +743,7 @@ abstract class BagOStuff implements
* @param int $resSig BagOStuff::RES_* constant describing the return value
* @param array $genericArgs Method arguments passed to the wrapper instance
* @param BagOStuff $wrapper The wrapper BagOStuff instance using this result
*
* @return mixed Method result with any keys remapped to "generic" keys
*/
protected function proxyCall(
@ -767,10 +807,15 @@ abstract class BagOStuff implements
/**
* @internal For testing only
*
* @param float|null &$time Mock UNIX timestamp
*
* @codeCoverageIgnore
*/
public function setMockTime( &$time ) {
$this->wallClockOverride =& $time;
}
}
/** @deprecated class alias since 1.43 */
class_alias( BagOStuff::class, 'BagOStuff' );

View file

@ -21,6 +21,8 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
/**
* Wrapper around a BagOStuff that caches data in memory
*
@ -42,6 +44,7 @@ class CachedBagOStuff extends BagOStuff {
/**
* @stable to call
*
* @param BagOStuff $backend Permanent backend to use
* @param array $params Parameters for HashBagOStuff
*/
@ -271,3 +274,6 @@ class CachedBagOStuff extends BagOStuff {
// @codeCoverageIgnoreEnd
}
/** @deprecated class alias since 1.43 */
class_alias( CachedBagOStuff::class, 'CachedBagOStuff' );

View file

@ -21,6 +21,8 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
/**
* A BagOStuff object with no objects in it. Used to provide a no-op object to calling code.
*
@ -61,3 +63,6 @@ class EmptyBagOStuff extends MediumSpecificBagOStuff {
return true;
}
}
/** @deprecated class alias since 1.43 */
class_alias( EmptyBagOStuff::class, 'EmptyBagOStuff' );

View file

@ -21,6 +21,10 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
use InvalidArgumentException;
/**
* Simple store for keeping values in an associative array for the current process.
*
@ -47,10 +51,12 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
/**
* @stable to call
*
* @param array $params Additional parameters include:
* - maxKeys : only allow this many keys (using oldest-first eviction)
*
* @phpcs:ignore Generic.Files.LineLength
* @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,segmentationSize?:int,segmentedValueMaxSize?:int,maxKeys?:int} $params
* @phan-param array{logger?:\Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,segmentationSize?:int,segmentedValueMaxSize?:int,maxKeys?:int} $params
*/
public function __construct( $params = [] ) {
$params['segmentationSize'] ??= INF;
@ -142,6 +148,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
/**
* @param string $key
*
* @return bool
*/
protected function expire( $key ) {
@ -159,6 +166,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
* Does this bag have a non-null value for the given key?
*
* @param string $key
*
* @return bool
* @since 1.27
*/
@ -166,3 +174,6 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
return isset( $this->bag[$key] );
}
}
/** @deprecated class alias since 1.43 */
class_alias( HashBagOStuff::class, 'HashBagOStuff' );

View file

@ -1,5 +1,7 @@
<?php
namespace Wikimedia\ObjectCache;
/**
* Key-encoding methods for object caching (BagOStuff and WANObjectCache)
*
@ -9,17 +11,24 @@
interface IStoreKeyEncoder {
/**
* @see BagOStuff::makeGlobalKey
*
* @param string $keygroup
* @param string|int ...$components
*
* @return string
*/
public function makeGlobalKey( $keygroup, ...$components );
/**
* @see BagOStuff::makeKey
*
* @param string $keygroup
* @param string|int ...$components
*
* @return string
*/
public function makeKey( $keygroup, ...$components );
}
/** @deprecated class alias since 1.43 */
class_alias( IStoreKeyEncoder::class, 'IStoreKeyEncoder' );

View file

@ -21,6 +21,12 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
use InvalidArgumentException;
use JsonSerializable;
use SerializedValueContainer;
use stdClass;
use Wikimedia\WaitConditionLoop;
/**
@ -81,9 +87,11 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* - segmentedValueMaxSize: The maximum total size, in bytes, of segmented values.
* This should be configured to a reasonable size give the site traffic and the
* amount of I/O between application and cache servers that the network can handle.
*
* @param array $params
*
* @phpcs:ignore Generic.Files.LineLength
* @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,reportDupes?:bool,segmentationSize?:int|float,segmentedValueMaxSize?:int} $params
* @phan-param array{logger?:\Psr\Log\LoggerInterface,asyncHandler?:callable,reportDupes?:bool,segmentationSize?:int|float,segmentedValueMaxSize?:int} $params
*/
public function __construct( array $params = [] ) {
parent::__construct( $params );
@ -109,6 +117,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
*
* @return mixed Returns false on failure or if the item does not exist
*/
public function get( $key, $flags = 0 ) {
@ -119,6 +128,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* Track the number of times that a given key has been used.
*
* @param string $key
*/
private function trackDuplicateKeys( $key ) {
@ -158,6 +168,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $flags Bitfield of BagOStuff::READ_* constants [optional]
* @param mixed &$casToken CAS token if MediumSpecificBagOStuff::PASS_BY_REF [returned]
*
* @return mixed Returns false on failure or if the item does not exist
*/
abstract protected function doGet( $key, $flags = 0, &$casToken = null );
@ -169,10 +180,12 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
public function set( $key, $value, $exptime = 0, $flags = 0 ) {
$entry = $this->makeValueOrSegmentList( $key, $value, $exptime, $flags, $ok );
// Only when all segments (if any) are stored should the main key be changed
return $ok && $this->doSet( $key, $entry, $exptime, $flags );
}
@ -184,6 +197,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
abstract protected function doSet( $key, $value, $exptime = 0, $flags = 0 );
@ -197,6 +211,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool True if the item was deleted or not found, false on failure
*/
public function delete( $key, $flags = 0 ) {
@ -229,12 +244,14 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool True if the item was deleted or not found, false on failure
*/
abstract protected function doDelete( $key, $flags = 0 );
public function add( $key, $value, $exptime = 0, $flags = 0 ) {
$entry = $this->makeValueOrSegmentList( $key, $value, $exptime, $flags, $ok );
// Only when all segments (if any) are stored should the main key be changed
return $ok && $this->doAdd( $key, $entry, $exptime, $flags );
}
@ -246,6 +263,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success
*/
abstract protected function doAdd( $key, $value, $exptime = 0, $flags = 0 );
@ -264,6 +282,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
@ -276,6 +295,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $attempts The amount of times to attempt a merge in case of failure
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
* @see BagOStuff::merge()
*/
@ -292,8 +312,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
if ( $this->getLastError( $watchPoint ) ) {
// Don't spam slow retries due to network problems (retry only on races)
$this->logger->warning(
__METHOD__ . ' failed due to read I/O error on get() for {key}.',
[ 'key' => $key ]
__METHOD__ . ' failed due to read I/O error on get() for {key}.', [ 'key' => $key ]
);
$success = false;
break;
@ -343,6 +362,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
protected function cas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
@ -357,6 +377,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
}
$entry = $this->makeValueOrSegmentList( $key, $value, $exptime, $flags, $ok );
// Only when all segments (if any) are stored should the main key be changed
return $ok && $this->doCas( $casToken, $key, $entry, $exptime, $flags );
}
@ -369,6 +390,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed $value
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
@ -407,6 +429,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param mixed $value CAS token for an existing key
* @param mixed $otherValue CAS token for an existing key
*
* @return bool Whether the two tokens match
*/
final protected function tokensMatch( $value, $otherValue ) {
@ -421,6 +444,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
if ( $type === 'array' || $type === 'object' ) {
return ( serialize( $value ) === serialize( $otherValue ) );
}
// For string/integer tokens, use a simple comparison
return ( $value === $otherValue );
}
@ -439,6 +463,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success Returns false on failure or if the item does not exist
* @since 1.28
*/
@ -450,6 +475,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $exptime
* @param int $flags
*
* @return bool
*/
protected function doChangeTTL( $key, $exptime, $flags ) {
@ -491,6 +517,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $step
* @param int $init
* @param int $flags
*
* @return int|bool New value or false on failure
*/
abstract protected function doIncrWithInit( $key, $exptime, $step, $init, $flags );
@ -500,6 +527,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $timeout
* @param int $exptime
* @param string $rclass
*
* @return bool
*/
public function lock( $key, $timeout = 6, $exptime = 6, $rclass = '' ) {
@ -536,6 +564,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string $key
* @param int $timeout Lock wait timeout; 0 for non-blocking [optional]
* @param int $exptime Lock time-to-live 1 day maximum [optional]
*
* @return float|null UNIX timestamp of acquisition; null on failure
*/
protected function doLock( $key, $timeout, $exptime ) {
@ -578,6 +607,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* Release an advisory lock on a key string
*
* @param string $key
*
* @return bool Success
*/
public function unlock( $key ) {
@ -610,6 +640,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @see MediumSpecificBagOStuff::unlock()
*
* @param string $key
*
* @return bool Success
*/
protected function doUnlock( $key ) {
@ -642,6 +673,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string $key
*
* @return string
*/
protected function makeLockKey( $key ) {
@ -659,8 +691,10 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* Get an associative array containing the item for each of the keys that have items.
*
* @param string[] $keys List of keys; can be a map of (unused => key) for convenience
* @param int $flags Bitfield; supports READ_LATEST [optional]
*
* @return mixed[] Map of (key => value) for existing keys; preserves the order of $keys
*/
public function getMulti( array $keys, $flags = 0 ) {
@ -683,8 +717,10 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* Get an associative array containing the item for each of the keys that have items.
*
* @param string[] $keys List of keys
* @param int $flags Bitfield; supports READ_LATEST [optional]
*
* @return array Map of (key => value) for existing keys; preserves the order of $keys
*/
protected function doGetMulti( array $keys, $flags = 0 ) {
@ -707,6 +743,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed[] $valueByKey Map of (key => value)
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success
* @since 1.24
*/
@ -722,6 +759,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param mixed[] $data Map of (key => value)
* @param int $exptime Either an interval in seconds or a unix timestamp for expiry
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
protected function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
@ -740,6 +778,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string[] $keys List of keys
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
* @since 1.33
*/
@ -754,6 +793,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string[] $keys List of keys
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
protected function doDeleteMulti( array $keys, $flags = 0 ) {
@ -761,6 +801,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
foreach ( $keys as $key ) {
$res = $this->doDelete( $key, $flags ) && $res;
}
return $res;
}
@ -770,6 +811,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string[] $keys List of keys
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants (since 1.33)
*
* @return bool Success
*
* @since 1.34
@ -782,6 +824,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param string[] $keys List of keys
* @param int $exptime TTL or UNIX timestamp
* @param int $flags Bitfield of BagOStuff::WRITE_* constants
*
* @return bool Success
*/
protected function doChangeTTLMulti( array $keys, $exptime, $flags = 0 ) {
@ -798,6 +841,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param string $key
* @param mixed $mainValue
*
* @return string|null|bool The combined string, false if missing, null on error
*/
final protected function resolveSegments( $key, $mainValue ) {
@ -837,6 +881,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param mixed $value
* @param int $flags
*
* @return bool
*/
private function useSegmentationWrapper( $value, $flags ) {
@ -872,6 +917,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* @param int $exptime
* @param int $flags
* @param mixed|null &$ok Whether the entry is usable (e.g. no missing segments) [returned]
*
* @return mixed The entry (inline value, wrapped inline value, or wrapped segment list)
* @since 1.34
*/
@ -912,6 +958,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param int|float $exptime
*
* @return bool Whether the expiry is non-infinite, and, negative or not a UNIX timestamp
* @since 1.34
*/
@ -929,6 +976,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* - positive (>= 10 years): absolute UNIX timestamp; return this value
*
* @param int $exptime
*
* @return int Expiration timestamp or TTL_INDEFINITE for indefinite
* @since 1.34
*/
@ -953,6 +1001,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* - positive (>= 10 years): absolute UNIX timestamp; return offset to current time
*
* @param int $exptime
*
* @return int Relative TTL or TTL_INDEFINITE for indefinite
* @since 1.34
*/
@ -970,6 +1019,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
* Check if a value is an integer
*
* @param mixed $value
*
* @return bool
*/
final protected function isInteger( $value ) {
@ -993,6 +1043,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*/
public function getSegmentationSize() {
wfDeprecated( __METHOD__, '1.43' );
return $this->segmentationSize;
}
@ -1001,6 +1052,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*/
public function getSegmentedValueMaxSize() {
wfDeprecated( __METHOD__, '1.43' );
return $this->segmentedValueMaxSize;
}
@ -1009,6 +1061,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
*
* @param mixed $value
* @param string $key
*
* @return string|int String/integer representation of value
* @since 1.35
*/
@ -1063,8 +1116,8 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
if ( is_object( $entry ) ) {
// Note that Closure instances count as objects
if (
!( $entry instanceof stdClass ) &&
!( $entry instanceof JsonSerializable )
!( $entry instanceof \stdClass ) &&
!( $entry instanceof \JsonSerializable )
) {
$this->logger->warning(
"{class} value for '{cachekey}' at '$index'; serialization is suspect.",
@ -1079,6 +1132,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param mixed $value
*
* @return string|int|false String/integer representation
* @note Special handling is usually needed for integers so incr()/decr() work
*/
@ -1088,6 +1142,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string|int|false $value
*
* @return mixed Original value or false on error
* @note Special handling is usually needed for integers so incr()/decr() work
*/
@ -1104,6 +1159,7 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
/**
* @param string $key Key generated by BagOStuff::makeKeyInternal
*
* @return string A stats prefix to describe this class of key (e.g. "objectcache.file")
*/
private function determinekeyGroupForStats( $key ): string {
@ -1192,3 +1248,6 @@ abstract class MediumSpecificBagOStuff extends BagOStuff {
}
}
}
/** @deprecated class alias since 1.43 */
class_alias( MediumSpecificBagOStuff::class, 'MediumSpecificBagOStuff' );

View file

@ -21,6 +21,12 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
use Exception;
use InvalidArgumentException;
use RuntimeException;
/**
* Base class for memcached clients.
*
@ -54,8 +60,10 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
*
* @since 1.27
* @see BagOStuff::makeKeyInternal
*
* @param string $keyspace
* @param string[]|int[] $components
*
* @return string
*/
protected function makeKeyInternal( $keyspace, $components ) {
@ -101,6 +109,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
* characters above the ASCII range.)
*
* @param string $key
*
* @return string
* @throws Exception
*/
@ -114,6 +123,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
/**
* @param string $key
*
* @return string
*/
protected function validateKeyAndPrependRoute( $key ) {
@ -132,6 +142,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
/**
* @param string $key
*
* @return string
*/
protected function stripRouteFromKey( $key ) {
@ -148,6 +159,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
/**
* @param int|float $exptime
*
* @return int
*/
protected function fixExpiry( $exptime ) {
@ -181,6 +193,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
* @param int $exptime
* @param int $step
* @param int $init
*
* @return bool True on success, false on failure
*/
abstract protected function doIncrWithInitAsync( $key, $exptime, $step, $init );
@ -190,7 +203,11 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
* @param int $exptime
* @param int $step
* @param int $init
*
* @return int|bool New value or false on failure
*/
abstract protected function doIncrWithInitSync( $key, $exptime, $step, $init );
}
/** @deprecated class alias since 1.43 */
class_alias( MemcachedBagOStuff::class, 'MemcachedBagOStuff' );

View file

@ -21,6 +21,11 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
use Memcached;
use RuntimeException;
use UnexpectedValueException;
use Wikimedia\ScopedCallback;
/**
@ -46,6 +51,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
* option igbinary.compact_strings is off.
* - use_binary_protocol Whether to enable the binary protocol (default is ASCII)
* - allow_tcp_nagle_delay Whether to permit Nagle's algorithm for reducing packet count
*
* @param array $params
*/
public function __construct( $params ) {
@ -86,6 +92,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
*
* @param Memcached $client
* @param array $params
*
* @throws RuntimeException
*/
private function initializeClient( Memcached $client, array $params ) {
@ -160,6 +167,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
* This makes writes much faster.
*
* @param bool|int $flags
*
* @return ScopedCallback|null
*/
private function noReplyScope( $flags ) {
@ -168,6 +176,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
}
$client = $this->client;
$client->setOption( Memcached::OPT_NOREPLY, true );
return new ScopedCallback( static function () use ( $client ) {
$client->setOption( Memcached::OPT_NOREPLY, false );
} );
@ -265,6 +274,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
$this->checkResult( $key, $this->client->increment( $routeKey, $step ) );
ScopedCallback::consume( $scope );
$lastError = $this->getLastError( $watchPoint );
return !$lastError;
}
@ -297,6 +307,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
*
* @param string|false $key The key used by the caller, or false if there wasn't one.
* @param mixed $result The return value
*
* @return mixed
*/
protected function checkResult( $key, $result ) {
@ -343,6 +354,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
$this->logger->error( $msg, $logCtx );
$this->setLastError( $statusByCode[$code] ?? self::ERR_UNEXPECTED );
}
return $result;
}
@ -369,6 +381,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
}
$res = $this->checkResult( false, $res );
return $res !== false ? $res : [];
}
@ -387,6 +400,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
$result = @$this->client->setMulti( $dataByRouteKey, $exptime );
ScopedCallback::consume( $noReplyScope );
return $this->checkResult( false, $result );
}
@ -454,3 +468,6 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
throw new UnexpectedValueException( __METHOD__ . ": got serializer '$serializer'." );
}
}
/** @deprecated class alias since 1.43 */
class_alias( MemcachedPeclBagOStuff::class, 'MemcachedPeclBagOStuff' );

View file

@ -21,6 +21,10 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
use MemcachedClient;
/**
* A wrapper class for the pure-PHP memcached client, exposing a BagOStuff interface.
*
@ -62,10 +66,8 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
$routeKey = $this->validateKeyAndPrependRoute( $key );
// T257003: only require "gets" (instead of "get") when a CAS token is needed
$res = $getToken
// @phan-suppress-next-line PhanTypeMismatchArgument False positive
? $this->client->get( $routeKey, $casToken )
: $this->client->get( $routeKey );
$res = $getToken // @phan-suppress-next-line PhanTypeMismatchArgument False positive
? $this->client->get( $routeKey, $casToken ) : $this->client->get( $routeKey );
if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
$this->setLastError( $this->client->_last_cmd_status );
@ -127,6 +129,7 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
$watchPoint = $this->watchErrors();
$this->client->add( $routeKey, $init - $step, $this->fixExpiry( $exptime ) );
$this->client->incr( $routeKey, $step );
return !$this->getLastError( $watchPoint );
}
@ -188,3 +191,6 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
return $this->isInteger( $value ) ? (int)$value : $this->client->unserialize( $value );
}
}
/** @deprecated class alias since 1.43 */
class_alias( MemcachedPhpBagOStuff::class, 'MemcachedPhpBagOStuff' );

View file

@ -20,6 +20,10 @@
* @file
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
use InvalidArgumentException;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
@ -47,6 +51,7 @@ class MultiWriteBagOStuff extends BagOStuff {
/**
* @stable to call
*
* @param array $params
* - caches: A numbered array of either ObjectFactory::getObjectFromSpec
* arrays yielding BagOStuff objects or direct BagOStuff objects.
@ -63,6 +68,7 @@ class MultiWriteBagOStuff extends BagOStuff {
* safe to use for modules when cached values: are immutable,
* invalidation uses logical TTLs, invalidation uses etag/timestamp
* validation against the DB, or merge() is used to handle races.
*
* @phan-param array{caches:array<int,array|BagOStuff>,replication:string} $params
* @throws InvalidArgumentException
*/
@ -321,6 +327,7 @@ class MultiWriteBagOStuff extends BagOStuff {
* @param int $arg0Sig BagOStuff::A0_* constant describing argument 0
* @param int $rvSig BagOStuff::RV_* constant describing the return value
* @param array $args Method arguments
*
* @return mixed The result of calling the given method
*/
private function callKeyMethodOnTierCache( $index, $method, $arg0Sig, $rvSig, array $args ) {
@ -335,6 +342,7 @@ class MultiWriteBagOStuff extends BagOStuff {
* @param int $arg0Sig BagOStuff::ARG0_* constant describing argument 0
* @param int $resSig BagOStuff::RES_* constant describing the return value
* @param array $args Method arguments
*
* @return mixed First synchronous result or false if any failed; null if all asynchronous
*/
private function callKeyWriteMethodOnTierCaches(
@ -377,3 +385,6 @@ class MultiWriteBagOStuff extends BagOStuff {
return $res;
}
}
/** @deprecated class alias since 1.43 */
class_alias( MultiWriteBagOStuff::class, 'MultiWriteBagOStuff' );

View file

@ -1,5 +1,9 @@
<?php
namespace Wikimedia\ObjectCache;
use InvalidArgumentException;
use LogicException;
use Psr\Log\LoggerInterface;
use Wikimedia\Http\MultiHttpClient;
@ -103,24 +107,28 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
/**
* REST URL to use for storage.
*
* @var string
*/
private $url;
/**
* HTTP parameters: readHeaders, writeHeaders, deleteHeaders, writeMethod.
*
* @var array
*/
private $httpParams;
/**
* Optional serialization type to use. Allowed values: "PHP", "JSON".
*
* @var string
*/
private $serializationType;
/**
* Optional HMAC Key for protecting the serialized blob. If omitted no protection is done
*
* @var string
*/
private $hmacKey;
@ -272,6 +280,7 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
* Processes the response body.
*
* @param string $body request body to process
*
* @return mixed|bool the processed body, or false on error
*/
private function decodeBody( $body ) {
@ -306,6 +315,7 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
* Prepares the request body (the "value" portion of our key/value store) for transmission.
*
* @param string $body request body to prepare
*
* @return string the prepared body
* @throws LogicException
*/
@ -375,3 +385,6 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
$this->setLastError( $rcode === 0 ? self::ERR_UNREACHABLE : self::ERR_UNEXPECTED );
}
}
/** @deprecated class alias since 1.43 */
class_alias( RESTBagOStuff::class, 'RESTBagOStuff' );

View file

@ -20,6 +20,15 @@
* @file
*/
namespace Wikimedia\ObjectCache;
use ArrayUtils;
use Exception;
use Redis;
use RedisConnectionPool;
use RedisConnRef;
use RedisException;
/**
* Redis-based caching module for redis server >= 2.6.12 and phpredis >= 2.2.4
*
@ -66,6 +75,7 @@ class RedisBagOStuff extends MediumSpecificBagOStuff {
* consistent hashing algorithm). True by default. This has the
* potential to create consistency issues if a server is slow enough to
* flap, for example if it is in swap death.
*
* @param array $params
*/
public function __construct( $params ) {
@ -440,6 +450,7 @@ LUA;
/**
* @param string[] $keys
*
* @return array ((server => redis handle wrapper), (server => key batch), success)
* @phan-return array{0:array<string,string[]>,1:array<string,RedisConnRef|Redis>,2:bool}
*/
@ -504,6 +515,7 @@ LUA;
/**
* @param string $key
*
* @return RedisConnRef|Redis|null Redis handle wrapper for the key or null on failure
*/
protected function getConnection( $key ) {
@ -527,6 +539,7 @@ LUA;
/**
* Log a fatal error
*
* @param string $msg
*/
protected function logError( $msg ) {
@ -538,6 +551,7 @@ LUA;
* and protocol errors. Sometimes it also closes the connection, sometimes
* not. The safest response for us is to explicitly destroy the connection
* object and let it be reopened during the next request.
*
* @param RedisConnRef $conn
* @param RedisException $e
*/
@ -548,6 +562,7 @@ LUA;
/**
* Send information about a single request to the debug log
*
* @param string $op
* @param string $keys
* @param string $server
@ -557,3 +572,6 @@ LUA;
$this->debug( "$op($keys) on $server: " . ( $e ? "failure" : "success" ) );
}
}
/** @deprecated class alias since 1.43 */
class_alias( RedisBagOStuff::class, 'RedisBagOStuff' );

View file

@ -18,6 +18,8 @@
* @file
* @ingroup Cache
*/
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
/**

View file

@ -21,6 +21,8 @@
* @ingroup Cache
*/
namespace Wikimedia\ObjectCache;
/**
* Wrapper for WinCache object caching functions; identical interface
* to the APC wrapper
@ -168,3 +170,6 @@ class WinCacheBagOStuff extends MediumSpecificBagOStuff {
return $newValue;
}
}
/** @deprecated class alias since 1.43 */
class_alias( WinCacheBagOStuff::class, 'WinCacheBagOStuff' );

View file

@ -25,6 +25,9 @@ use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikimedia\LightweightObjectStore\ExpirationAwareness;
use Wikimedia\LightweightObjectStore\StorageAwareness;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\IStoreKeyEncoder;
/**
* Multi-datacenter aware caching interface

View file

@ -19,12 +19,12 @@
*/
namespace Wikimedia\Rdbms;
use BagOStuff;
use EmptyBagOStuff;
use LogicException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
/**
* Provide a given client with protection against visible database lag.

View file

@ -19,10 +19,10 @@
*/
namespace Wikimedia\Rdbms;
use HashBagOStuff;
use InvalidArgumentException;
use Psr\Log\NullLogger;
use Throwable;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\RequestTimeout\CriticalSectionProvider;
/**

View file

@ -19,8 +19,8 @@
*/
namespace Wikimedia\Rdbms\Replication;
use BagOStuff;
use Psr\Log\LoggerInterface;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\DBError;
use Wikimedia\Rdbms\DBPrimaryPos;
use Wikimedia\Rdbms\IDatabase;

View file

@ -19,8 +19,6 @@
*/
namespace Wikimedia\Rdbms;
use BagOStuff;
use EmptyBagOStuff;
use Exception;
use Generator;
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
@ -30,6 +28,8 @@ use Psr\Log\NullLogger;
use RuntimeException;
use Throwable;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\RequestTimeout\CriticalSectionProvider;
use Wikimedia\ScopedCallback;

View file

@ -20,8 +20,6 @@
namespace Wikimedia\Rdbms;
use ArrayUtils;
use BagOStuff;
use EmptyBagOStuff;
use InvalidArgumentException;
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
use LogicException;
@ -32,6 +30,8 @@ use RuntimeException;
use Throwable;
use UnexpectedValueException;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ScopedCallback;
/**

View file

@ -19,10 +19,10 @@
*/
namespace Wikimedia\Rdbms;
use BagOStuff;
use Psr\Log\LoggerAwareInterface;
use StatsdAwareInterface;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
/**
* Database load monitoring interface

View file

@ -19,14 +19,14 @@
*/
namespace Wikimedia\Rdbms;
use BagOStuff;
use IStoreKeyEncoder;
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
use NullStatsdDataFactory;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use RuntimeException;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\IStoreKeyEncoder;
use Wikimedia\Rdbms\Platform\ISQLPlatform;
use Wikimedia\ScopedCallback;

View file

@ -20,12 +20,12 @@
namespace MediaWiki\Linker;
use BagOStuff;
use InvalidArgumentException;
use MediaWiki\Title\TitleValue;
use RuntimeException;
use stdClass;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\IConnectionProvider;
use Wikimedia\Rdbms\IDatabase;

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\MediaWikiServices;
use Wikimedia\ObjectCache\BagOStuff;
/**
* @see ObjectCacheFactory

View file

@ -24,6 +24,14 @@ use MediaWiki\Http\Telemetry;
use MediaWiki\Logger\Spi;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use Wikimedia\ObjectCache\APCUBagOStuff;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ObjectCache\MemcachedBagOStuff;
use Wikimedia\ObjectCache\MultiWriteBagOStuff;
use Wikimedia\ObjectCache\RESTBagOStuff;
use Wikimedia\ObjectCache\WinCacheBagOStuff;
use Wikimedia\Stats\StatsFactory;
/**

View file

@ -23,6 +23,7 @@
use MediaWiki\MediaWikiServices;
use Wikimedia\AtEase\AtEase;
use Wikimedia\ObjectCache\MediumSpecificBagOStuff;
use Wikimedia\Rdbms\Blob;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\DBConnectionError;

View file

@ -3,7 +3,6 @@
namespace MediaWiki\Page;
use BadMethodCallException;
use BagOStuff;
use ChangeTags;
use Content;
use DeletePageJob;
@ -40,6 +39,7 @@ use StatusValue;
use Wikimedia\IPUtils;
use Wikimedia\Message\ITextFormatter;
use Wikimedia\Message\MessageValue;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\LBFactory;
use Wikimedia\RequestTimeout\TimeoutException;
use WikiPage;

View file

@ -2,13 +2,13 @@
namespace MediaWiki\Page\File;
use BagOStuff;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\Title\MalformedTitleException;
use MediaWiki\Title\TitleParser;
use RepoGroup;
use Wikimedia\ObjectCache\BagOStuff;
class BadFileLookup {
/** @var callable Returns contents of bad file list (see comment for isBadFile()) */

View file

@ -21,7 +21,6 @@
namespace MediaWiki\Page;
use BagOStuff;
use ContentModelChange;
use JobQueueGroup;
use MediaWiki\Cache\BacklinkCacheFactory;
@ -51,6 +50,7 @@ use MediaWiki\Watchlist\WatchedItemStoreInterface;
use Psr\Log\LoggerInterface;
use RepoGroup;
use Wikimedia\Message\ITextFormatter;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\LBFactory;
use Wikimedia\Rdbms\ReadOnlyMode;
use WikiPage;

View file

@ -31,6 +31,9 @@ use MediaWiki\Parser\ParserCacheMetadata;
use MediaWiki\Parser\ParserOutput;
use MediaWiki\Title\TitleFactory;
use Psr\Log\LoggerInterface;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Stats\StatsFactory;
use Wikimedia\UUID\GlobalIdGenerator;

View file

@ -21,7 +21,6 @@
namespace MediaWiki\Parser;
use BagOStuff;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Json\JsonCodec;
@ -31,6 +30,7 @@ use MediaWiki\Title\TitleFactory;
use ParserCache;
use Psr\Log\LoggerInterface;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Stats\StatsFactory;
use Wikimedia\UUID\GlobalIdGenerator;

View file

@ -5,6 +5,7 @@ use MediaWiki\Settings\SettingsBuilder;
use MediaWiki\Shell\Shell;
use MediaWiki\ShellDisabledError;
use MediaWiki\WikiMap\WikiMap;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ScopedCallback;
/**

View file

@ -1,5 +1,6 @@
<?php
use MediaWiki\Html\TemplateParser;
use Wikimedia\ObjectCache\EmptyBagOStuff;
/**
* Thrown when ExtensionRegistry cannot open the extension.json or skin.json file.

View file

@ -23,13 +23,13 @@
namespace MediaWiki\Session;
use BagOStuff;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use SessionHandlerInterface;
use Wikimedia\AtEase\AtEase;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\PhpSessionSerializer;
/**

View file

@ -23,7 +23,6 @@
namespace MediaWiki\Session;
use CachedBagOStuff;
use InvalidArgumentException;
use MediaWiki\Deferred\DeferredUpdates;
use MediaWiki\HookContainer\HookContainer;
@ -35,6 +34,7 @@ use MediaWiki\User\User;
use MWRestrictions;
use Psr\Log\LoggerInterface;
use Wikimedia\AtEase\AtEase;
use Wikimedia\ObjectCache\CachedBagOStuff;
/**
* This is the actual workhorse for Session.

View file

@ -23,8 +23,6 @@
namespace MediaWiki\Session;
use BagOStuff;
use CachedBagOStuff;
use InvalidArgumentException;
use LogicException;
use MediaWiki\Config\Config;
@ -40,6 +38,8 @@ use MediaWiki\User\UserNameUtils;
use MWException;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\CachedBagOStuff;
/**
* This serves as the entry point to the MediaWiki session handling system.

View file

@ -20,7 +20,7 @@
namespace MediaWiki\Site;
use BagOStuff;
use Wikimedia\ObjectCache\BagOStuff;
/**
* Hold a configured list of sites (SiteList), with a caching layer.

View file

@ -39,6 +39,7 @@ use MediaWiki\User\User;
use MediaWiki\User\UserIdentity;
use Wikimedia\AtEase\AtEase;
use Wikimedia\FileBackend\FileBackend;
use Wikimedia\ObjectCache\BagOStuff;
/**
* @defgroup Upload Upload related

View file

@ -1,4 +1,9 @@
<?php
use Wikimedia\ObjectCache\APCUBagOStuff;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
/**
* Generate hash digests of file contents to help with cache invalidation.
*

View file

@ -2,9 +2,7 @@
namespace MediaWiki\Watchlist;
use BagOStuff;
use DateInterval;
use HashBagOStuff;
use JobQueueGroup;
use LogicException;
use MapCacheLRU;
@ -21,6 +19,8 @@ use MediaWiki\User\UserIdentity;
use MediaWiki\Utils\MWTimestamp;
use stdClass;
use Wikimedia\Assert\Assert;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ParamValidator\TypeDef\ExpiryDef;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\ILBFactory;

View file

@ -19,6 +19,8 @@
* @ingroup Benchmark
*/
use Wikimedia\ObjectCache\HashBagOStuff;
require_once __DIR__ . '/../includes/Benchmarker.php';
/**

View file

@ -23,6 +23,7 @@
*/
use MediaWiki\MainConfigNames;
use Wikimedia\ObjectCache\BagOStuff;
require_once __DIR__ . '/Maintenance.php';

View file

@ -32,6 +32,8 @@ use MediaWiki\User\User;
use MediaWiki\User\UserIdentityValue;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\ChangedTablesTracker;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;

View file

@ -2,13 +2,13 @@
namespace MediaWiki\Tests\ResourceLoader;
use HashBagOStuff;
use MediaWiki\ResourceLoader\MessageBlobStore;
use MediaWiki\ResourceLoader\ResourceLoader;
use MediaWikiCoversValidator;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
use WANObjectCache;
use Wikimedia\ObjectCache\HashBagOStuff;
/**
* @group ResourceLoader

View file

@ -4,7 +4,6 @@ namespace MediaWiki\Tests\Revision;
use Content;
use Exception;
use HashBagOStuff;
use IDBAccessObject;
use InvalidArgumentException;
use MediaWiki\CommentStore\CommentStoreComment;
@ -39,6 +38,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use StatusValue;
use WANObjectCache;
use Wikimedia\Assert\PreconditionException;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\DatabaseDomain;
use Wikimedia\Rdbms\DatabaseSqlite;

View file

@ -1,6 +1,7 @@
<?php
use MediaWiki\SiteStats\SiteStats;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\Platform\ISQLPlatform;
/**

View file

@ -2,7 +2,6 @@
namespace MediaWiki\Tests\Storage;
use BagOStuff;
use Content;
use ContentHandler;
use DummyContentHandlerForTesting;
@ -38,6 +37,7 @@ use MediaWikiIntegrationTestCase;
use MockTitleTrait;
use ParserOptions;
use PHPUnit\Framework\MockObject\MockObject;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\Rdbms\Platform\ISQLPlatform;
use Wikimedia\TestingAccessWrapper;
use Wikimedia\Timestamp\ConvertibleTimestamp;

View file

@ -2,9 +2,6 @@
namespace MediaWiki\Tests\Storage;
use BagOStuff;
use EmptyBagOStuff;
use HashBagOStuff;
use MediaWiki\Storage\NameTableAccessException;
use MediaWiki\Storage\NameTableStore;
use MediaWikiIntegrationTestCase;
@ -12,6 +9,9 @@ use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\NullLogger;
use RuntimeException;
use WANObjectCache;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\InsertQueryBuilder;
use Wikimedia\Rdbms\LoadBalancer;

View file

@ -5,7 +5,6 @@ namespace MediaWiki\Tests\Storage;
use ConcatenatedGzipHistoryBlob;
use ExternalStoreAccess;
use ExternalStoreFactory;
use HashBagOStuff;
use InvalidArgumentException;
use MediaWiki\Storage\BadBlobException;
use MediaWiki\Storage\BlobAccessException;
@ -13,6 +12,7 @@ use MediaWiki\Storage\SqlBlobStore;
use MediaWikiIntegrationTestCase;
use StatusValue;
use WANObjectCache;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\LoadBalancer;
/**

View file

@ -2,7 +2,6 @@
namespace MediaWiki\Tests\Api;
use HashBagOStuff;
use MediaWiki\Content\CssContent;
use MediaWiki\Storage\PageEditStash;
use MediaWiki\Tests\User\TempUser\TempUserTestTrait;
@ -12,6 +11,7 @@ use MediaWiki\User\UserIdentity;
use MediaWiki\User\UserRigorOptions;
use Psr\Log\NullLogger;
use stdClass;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Stats\StatsFactory;
use Wikimedia\TestingAccessWrapper;
use Wikimedia\Timestamp\ConvertibleTimestamp;

View file

@ -7,7 +7,6 @@ use DomainException;
use DummySessionProvider;
use DynamicPropertyTestHelper;
use Exception;
use HashBagOStuff;
use InvalidArgumentException;
use Language;
use LogicException;
@ -75,6 +74,7 @@ use StatusValue;
use TestLogger;
use TestUser;
use UnexpectedValueException;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
use Wikimedia\Rdbms\ILoadBalancer;
use Wikimedia\Rdbms\ReadOnlyMode;

View file

@ -2,7 +2,6 @@
namespace MediaWiki\Tests\Auth;
use HashBagOStuff;
use MediaWiki\Auth\AuthenticationResponse;
use MediaWiki\Auth\ThrottlePreAuthenticationProvider;
use MediaWiki\Auth\UsernameAuthenticationRequest;
@ -15,6 +14,7 @@ use Psr\Log\LogLevel;
use StatusValue;
use stdClass;
use TestLogger;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\TestingAccessWrapper;
/**

View file

@ -2,8 +2,6 @@
namespace MediaWiki\Tests\Auth;
use BagOStuff;
use HashBagOStuff;
use InvalidArgumentException;
use MediaWiki\Auth\Throttler;
use MediaWiki\MainConfigNames;
@ -11,6 +9,8 @@ use MediaWikiIntegrationTestCase;
use Psr\Log\AbstractLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\TestingAccessWrapper;
/**

View file

@ -5,6 +5,8 @@ use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
use MediaWiki\Title\Title;
use MediaWiki\Title\TitleValue;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
/**
* @group Database

View file

@ -3,6 +3,7 @@
use MediaWiki\Tests\Unit\Libs\Rdbms\AddQuoterMock;
use MediaWiki\Tests\Unit\Libs\Rdbms\SQLPlatformTestHelper;
use Psr\Log\NullLogger;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\Database\DatabaseFlags;
use Wikimedia\Rdbms\DatabaseDomain;

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\WikiMap\WikiMap;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\Rdbms\ChronologyProtector;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\DatabaseDomain;

View file

@ -5,6 +5,7 @@ use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
use MediaWiki\MainConfigNames;
use MediaWiki\Tests\Unit\DummyServicesTrait;
use MediaWiki\WikiMap\WikiMap;
use Wikimedia\ObjectCache\EmptyBagOStuff;
/**
* @coversDefaultClass \MediaWiki\FileBackend\FileBackendGroup

View file

@ -4,6 +4,8 @@ use MediaWiki\MainConfigNames;
use MediaWiki\Status\Status;
use MediaWiki\Title\Title;
use MediaWiki\WikiMap\WikiMap;
use Wikimedia\ObjectCache\EmptyBagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
/**
* @group Database

View file

@ -12,6 +12,7 @@ use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
use MediaWiki\Title\Title;
use MediaWiki\User\UserIdentity;
use MediaWiki\WikiMap\WikiMap;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\TestingAccessWrapper;
/**

View file

@ -2,6 +2,7 @@
use MediaWiki\MediaWikiServices;
use MediaWiki\WikiMap\WikiMap;
use Wikimedia\ObjectCache\HashBagOStuff;
/**
* @group JobQueue

View file

@ -1,8 +1,10 @@
<?php
use Wikimedia\ObjectCache\APCUBagOStuff;
/**
* @group BagOStuff
* @covers \APCUBagOStuff
* @covers \Wikimedia\ObjectCache\APCUBagOStuff
* @requires extension apcu
*/
class APCUBagOStuffTest extends BagOStuffTestBase {

View file

@ -2,14 +2,17 @@
use MediaWiki\Deferred\DeferredUpdates;
use Wikimedia\LightweightObjectStore\StorageAwareness;
use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectCache\HashBagOStuff;
use Wikimedia\ObjectCache\MultiWriteBagOStuff;
use Wikimedia\ScopedCallback;
use Wikimedia\TestingAccessWrapper;
/**
* @author Matthias Mullie <mmullie@wikimedia.org>
* @group BagOStuff
* @covers \BagOStuff
* @covers \MediumSpecificBagOStuff
* @covers \Wikimedia\ObjectCache\BagOStuff
* @covers \Wikimedia\ObjectCache\MediumSpecificBagOStuff
*/
abstract class BagOStuffTestBase extends MediaWikiIntegrationTestCase {
/** @var BagOStuff */

Some files were not shown because too many files have changed in this diff Show more