aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorEbrahim Byagowi <ebrahim@gnu.org>2024-07-09 17:07:44 +0330
committerEbrahim Byagowi <ebrahim@gnu.org>2024-07-10 00:14:54 +0330
commitfab78547ad13e4579c728ad0f59a00d95e9eb53d (patch)
tree3fb786a84e9715fcb712207972e871975df6aed9 /includes
parent0985ed781c261a35b2580ed41c4501c61f51b4cf (diff)
downloadmediawikicore-fab78547ad13e4579c728ad0f59a00d95e9eb53d.tar.gz
mediawikicore-fab78547ad13e4579c728ad0f59a00d95e9eb53d.zip
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
Diffstat (limited to 'includes')
-rw-r--r--includes/Html/TemplateParser.php2
-rw-r--r--includes/MainConfigSchema.php18
-rw-r--r--includes/MediaWikiServices.php2
-rw-r--r--includes/Output/NoLocalSettings.php1
-rw-r--r--includes/ResourceLoader/ResourceLoader.php4
-rw-r--r--includes/ResourceLoader/dependencystore/KeyValueDependencyStore.php2
-rw-r--r--includes/Rest/Router.php2
-rw-r--r--includes/Revision/RevisionStore.php2
-rw-r--r--includes/Revision/RevisionStoreFactory.php2
-rw-r--r--includes/ServiceWiring.php3
-rw-r--r--includes/Settings/Cache/CachedSource.php2
-rw-r--r--includes/Settings/SettingsBuilder.php2
-rw-r--r--includes/Storage/EditResultCache.php2
-rw-r--r--includes/Storage/PageEditStash.php2
-rw-r--r--includes/auth/ThrottlePreAuthenticationProvider.php2
-rw-r--r--includes/auth/Throttler.php2
-rw-r--r--includes/cache/FileCacheBase.php2
-rw-r--r--includes/config-schema.php14
-rw-r--r--includes/config/EtcdConfig.php4
-rw-r--r--includes/db/MWLBFactory.php1
-rw-r--r--includes/edit/SimpleParsoidOutputStash.php2
-rw-r--r--includes/filebackend/FileBackendGroup.php2
-rw-r--r--includes/installer/Installer.php2
-rw-r--r--includes/installer/Pingback.php2
-rw-r--r--includes/jobqueue/JobQueueMemory.php2
-rw-r--r--includes/language/LanguageConverter.php1
-rw-r--r--includes/language/LanguageNameUtils.php4
-rw-r--r--includes/language/MessageCache.php2
-rw-r--r--includes/language/dependency/DependencyWrapper.php2
-rw-r--r--includes/libs/CryptHKDF.php3
-rw-r--r--includes/libs/WRStats/BagOStuffStatsStore.php2
-rw-r--r--includes/libs/filebackend/FileBackendStore.php2
-rw-r--r--includes/libs/filebackend/SwiftFileBackend.php2
-rw-r--r--includes/libs/lockmanager/MemcLockManager.php3
-rw-r--r--includes/libs/objectcache/APCUBagOStuff.php5
-rw-r--r--includes/libs/objectcache/BagOStuff.php49
-rw-r--r--includes/libs/objectcache/CachedBagOStuff.php6
-rw-r--r--includes/libs/objectcache/EmptyBagOStuff.php5
-rw-r--r--includes/libs/objectcache/HashBagOStuff.php13
-rw-r--r--includes/libs/objectcache/IStoreKeyEncoder.php9
-rw-r--r--includes/libs/objectcache/MediumSpecificBagOStuff.php69
-rw-r--r--includes/libs/objectcache/MemcachedBagOStuff.php17
-rw-r--r--includes/libs/objectcache/MemcachedPeclBagOStuff.php17
-rw-r--r--includes/libs/objectcache/MemcachedPhpBagOStuff.php14
-rw-r--r--includes/libs/objectcache/MultiWriteBagOStuff.php11
-rw-r--r--includes/libs/objectcache/RESTBagOStuff.php13
-rw-r--r--includes/libs/objectcache/RedisBagOStuff.php18
-rw-r--r--includes/libs/objectcache/ReplicatedBagOStuff.php2
-rw-r--r--includes/libs/objectcache/WinCacheBagOStuff.php5
-rw-r--r--includes/libs/objectcache/wancache/WANObjectCache.php3
-rw-r--r--includes/libs/rdbms/ChronologyProtector.php4
-rw-r--r--includes/libs/rdbms/database/DatabaseFactory.php2
-rw-r--r--includes/libs/rdbms/database/replication/ReplicationReporter.php2
-rw-r--r--includes/libs/rdbms/lbfactory/LBFactory.php4
-rw-r--r--includes/libs/rdbms/loadbalancer/LoadBalancer.php4
-rw-r--r--includes/libs/rdbms/loadmonitor/ILoadMonitor.php2
-rw-r--r--includes/libs/rdbms/loadmonitor/LoadMonitor.php4
-rw-r--r--includes/linker/LinkTargetStore.php2
-rw-r--r--includes/objectcache/ObjectCache.php1
-rw-r--r--includes/objectcache/ObjectCacheFactory.php8
-rw-r--r--includes/objectcache/SqlBagOStuff.php1
-rw-r--r--includes/page/DeletePage.php2
-rw-r--r--includes/page/File/BadFileLookup.php2
-rw-r--r--includes/page/PageCommandFactory.php2
-rw-r--r--includes/parser/ParserCache.php3
-rw-r--r--includes/parser/ParserCacheFactory.php2
-rw-r--r--includes/registration/ExtensionRegistry.php1
-rw-r--r--includes/registration/MissingExtensionException.php1
-rw-r--r--includes/session/PHPSessionHandler.php2
-rw-r--r--includes/session/SessionBackend.php2
-rw-r--r--includes/session/SessionManager.php4
-rw-r--r--includes/site/CachingSiteStore.php2
-rw-r--r--includes/upload/UploadBase.php1
-rw-r--r--includes/utils/FileContentsHasher.php5
-rw-r--r--includes/watchlist/WatchedItemStore.php4
75 files changed, 350 insertions, 75 deletions
diff --git a/includes/Html/TemplateParser.php b/includes/Html/TemplateParser.php
index 4e921cad4ddb..f4f953f993fe 100644
--- a/includes/Html/TemplateParser.php
+++ b/includes/Html/TemplateParser.php
@@ -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
diff --git a/includes/MainConfigSchema.php b/includes/MainConfigSchema.php
index 695b3cb0af60..50e5c9fd4413 100644
--- a/includes/MainConfigSchema.php
+++ b/includes/MainConfigSchema.php
@@ -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 = [
diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php
index 15da1e738a3b..6d1a4df9df97 100644
--- a/includes/MediaWikiServices.php
+++ b/includes/MediaWikiServices.php
@@ -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;
diff --git a/includes/Output/NoLocalSettings.php b/includes/Output/NoLocalSettings.php
index 1f766d532fcd..694b1354cbb0 100644
--- a/includes/Output/NoLocalSettings.php
+++ b/includes/Output/NoLocalSettings.php
@@ -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 = '/';
diff --git a/includes/ResourceLoader/ResourceLoader.php b/includes/ResourceLoader/ResourceLoader.php
index bd00db0bdd40..c295020cb28b 100644
--- a/includes/ResourceLoader/ResourceLoader.php
+++ b/includes/ResourceLoader/ResourceLoader.php
@@ -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;
diff --git a/includes/ResourceLoader/dependencystore/KeyValueDependencyStore.php b/includes/ResourceLoader/dependencystore/KeyValueDependencyStore.php
index 5fcda5b0fd52..a0cf3104dbb1 100644
--- a/includes/ResourceLoader/dependencystore/KeyValueDependencyStore.php
+++ b/includes/ResourceLoader/dependencystore/KeyValueDependencyStore.php
@@ -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.
diff --git a/includes/Rest/Router.php b/includes/Rest/Router.php
index 0018e164714d..ed6f789f2f73 100644
--- a/includes/Rest/Router.php
+++ b/includes/Rest/Router.php
@@ -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;
diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php
index b6765e74acaf..4807cb11d0c5 100644
--- a/includes/Revision/RevisionStore.php
+++ b/includes/Revision/RevisionStore.php
@@ -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;
diff --git a/includes/Revision/RevisionStoreFactory.php b/includes/Revision/RevisionStoreFactory.php
index 7f38a5992bb3..14a82444b14b 100644
--- a/includes/Revision/RevisionStoreFactory.php
+++ b/includes/Revision/RevisionStoreFactory.php
@@ -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;
/**
diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index 59ddb0fc1d86..15ea48820fd7 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -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;
diff --git a/includes/Settings/Cache/CachedSource.php b/includes/Settings/Cache/CachedSource.php
index ef0ee57b1683..2f00595c313d 100644
--- a/includes/Settings/Cache/CachedSource.php
+++ b/includes/Settings/Cache/CachedSource.php
@@ -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;
/**
diff --git a/includes/Settings/SettingsBuilder.php b/includes/Settings/SettingsBuilder.php
index 2651d739981d..70c6fbc09aec 100644
--- a/includes/Settings/SettingsBuilder.php
+++ b/includes/Settings/SettingsBuilder.php
@@ -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;
/**
diff --git a/includes/Storage/EditResultCache.php b/includes/Storage/EditResultCache.php
index 04e04f2bf734..50107d49bf2f 100644
--- a/includes/Storage/EditResultCache.php
+++ b/includes/Storage/EditResultCache.php
@@ -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;
/**
diff --git a/includes/Storage/PageEditStash.php b/includes/Storage/PageEditStash.php
index 6afdb7177f41..c2beb3782efc 100644
--- a/includes/Storage/PageEditStash.php
+++ b/includes/Storage/PageEditStash.php
@@ -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;
diff --git a/includes/auth/ThrottlePreAuthenticationProvider.php b/includes/auth/ThrottlePreAuthenticationProvider.php
index b393e6137db4..74ffd79289bd 100644
--- a/includes/auth/ThrottlePreAuthenticationProvider.php
+++ b/includes/auth/ThrottlePreAuthenticationProvider.php
@@ -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.
diff --git a/includes/auth/Throttler.php b/includes/auth/Throttler.php
index cd3fdd4f9c63..21a382cfbce2 100644
--- a/includes/auth/Throttler.php
+++ b/includes/auth/Throttler.php
@@ -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.
diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php
index 94f6f94cb574..d1252fe7f059 100644
--- a/includes/cache/FileCacheBase.php
+++ b/includes/cache/FileCacheBase.php
@@ -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.
diff --git a/includes/config-schema.php b/includes/config-schema.php
index 1a3213ea72fa..81f3c3cf4f05 100644
--- a/includes/config-schema.php
+++ b/includes/config-schema.php
@@ -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,
],
],
diff --git a/includes/config/EtcdConfig.php b/includes/config/EtcdConfig.php
index 63cb4608f547..b9a66eec803b 100644
--- a/includes/config/EtcdConfig.php
+++ b/includes/config/EtcdConfig.php
@@ -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;
diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php
index aea6f2b7cecb..d7ce119c8569 100644
--- a/includes/db/MWLBFactory.php
+++ b/includes/db/MWLBFactory.php
@@ -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;
diff --git a/includes/edit/SimpleParsoidOutputStash.php b/includes/edit/SimpleParsoidOutputStash.php
index cfdbb7903fdf..a19db49e7b4c 100644
--- a/includes/edit/SimpleParsoidOutputStash.php
+++ b/includes/edit/SimpleParsoidOutputStash.php
@@ -2,9 +2,9 @@
namespace MediaWiki\Edit;
-use BagOStuff;
use MediaWiki\Content\IContentHandlerFactory;
use MediaWiki\Parser\Parsoid\PageBundleJsonTrait;
+use Wikimedia\ObjectCache\BagOStuff;
/**
* @internal
diff --git a/includes/filebackend/FileBackendGroup.php b/includes/filebackend/FileBackendGroup.php
index aed10f1477a6..5f0f7acc1109 100644
--- a/includes/filebackend/FileBackendGroup.php
+++ b/includes/filebackend/FileBackendGroup.php
@@ -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;
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index 5e1391ffbddc..f4923f20238c 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -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;
diff --git a/includes/installer/Pingback.php b/includes/installer/Pingback.php
index 4197213354be..ec0559fdf08a 100644
--- a/includes/installer/Pingback.php
+++ b/includes/installer/Pingback.php
@@ -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;
diff --git a/includes/jobqueue/JobQueueMemory.php b/includes/jobqueue/JobQueueMemory.php
index 56149077358a..37bbdc2f8923 100644
--- a/includes/jobqueue/JobQueueMemory.php
+++ b/includes/jobqueue/JobQueueMemory.php
@@ -18,6 +18,8 @@
* @file
*/
+use Wikimedia\ObjectCache\HashBagOStuff;
+
/**
* PHP memory-backed job queue storage, for testing.
*
diff --git a/includes/language/LanguageConverter.php b/includes/language/LanguageConverter.php
index a1c740cdab12..c013790c1233 100644
--- a/includes/language/LanguageConverter.php
+++ b/includes/language/LanguageConverter.php
@@ -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.
diff --git a/includes/language/LanguageNameUtils.php b/includes/language/LanguageNameUtils.php
index 313b3df019f0..aa5a7d3d5441 100644
--- a/includes/language/LanguageNameUtils.php
+++ b/includes/language/LanguageNameUtils.php
@@ -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.
diff --git a/includes/language/MessageCache.php b/includes/language/MessageCache.php
index 8ff315c609d3..c22c90dfeb89 100644
--- a/includes/language/MessageCache.php
+++ b/includes/language/MessageCache.php
@@ -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;
diff --git a/includes/language/dependency/DependencyWrapper.php b/includes/language/dependency/DependencyWrapper.php
index 45b1ffc3382c..ade7d3327c6e 100644
--- a/includes/language/dependency/DependencyWrapper.php
+++ b/includes/language/dependency/DependencyWrapper.php
@@ -18,6 +18,8 @@
* @file
*/
+use Wikimedia\ObjectCache\BagOStuff;
+
/**
* Store an arbitrary value whilst representing several CacheDependency objects as one.
*
diff --git a/includes/libs/CryptHKDF.php b/includes/libs/CryptHKDF.php
index 80e4aa0b79f6..4ee893cdbfe6 100644
--- a/includes/libs/CryptHKDF.php
+++ b/includes/libs/CryptHKDF.php
@@ -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.
diff --git a/includes/libs/WRStats/BagOStuffStatsStore.php b/includes/libs/WRStats/BagOStuffStatsStore.php
index eff03346e894..54eaca08546b 100644
--- a/includes/libs/WRStats/BagOStuffStatsStore.php
+++ b/includes/libs/WRStats/BagOStuffStatsStore.php
@@ -2,7 +2,7 @@
namespace Wikimedia\WRStats;
-use BagOStuff;
+use Wikimedia\ObjectCache\BagOStuff;
/**
* An adaptor allowing WRStats to store data in MediaWiki's BagOStuff
diff --git a/includes/libs/filebackend/FileBackendStore.php b/includes/libs/filebackend/FileBackendStore.php
index 7b93d71fe74d..8a36e2f0648e 100644
--- a/includes/libs/filebackend/FileBackendStore.php
+++ b/includes/libs/filebackend/FileBackendStore.php
@@ -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;
/**
diff --git a/includes/libs/filebackend/SwiftFileBackend.php b/includes/libs/filebackend/SwiftFileBackend.php
index c2eef4e52b54..82ddfd85caeb 100644
--- a/includes/libs/filebackend/SwiftFileBackend.php
+++ b/includes/libs/filebackend/SwiftFileBackend.php
@@ -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;
/**
diff --git a/includes/libs/lockmanager/MemcLockManager.php b/includes/libs/lockmanager/MemcLockManager.php
index b59acc736f5c..43259d6acaf7 100644
--- a/includes/libs/lockmanager/MemcLockManager.php
+++ b/includes/libs/lockmanager/MemcLockManager.php
@@ -17,6 +17,9 @@
*
* @file
*/
+
+use Wikimedia\ObjectCache\MemcachedBagOStuff;
+use Wikimedia\ObjectCache\MemcachedPhpBagOStuff;
use Wikimedia\WaitConditionLoop;
/**
diff --git a/includes/libs/objectcache/APCUBagOStuff.php b/includes/libs/objectcache/APCUBagOStuff.php
index 8395fb75d262..9f88883b374f 100644
--- a/includes/libs/objectcache/APCUBagOStuff.php
+++ b/includes/libs/objectcache/APCUBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php
index 96a79924c872..41d076213ce2 100644
--- a/includes/libs/objectcache/BagOStuff.php
+++ b/includes/libs/objectcache/BagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php
index 72662e6f5a01..80163e8e2839 100644
--- a/includes/libs/objectcache/CachedBagOStuff.php
+++ b/includes/libs/objectcache/CachedBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/EmptyBagOStuff.php b/includes/libs/objectcache/EmptyBagOStuff.php
index d9d1c314153b..eef3cc0017d3 100644
--- a/includes/libs/objectcache/EmptyBagOStuff.php
+++ b/includes/libs/objectcache/EmptyBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/HashBagOStuff.php b/includes/libs/objectcache/HashBagOStuff.php
index aebbaf3ed4db..07b74fbfbd90 100644
--- a/includes/libs/objectcache/HashBagOStuff.php
+++ b/includes/libs/objectcache/HashBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/IStoreKeyEncoder.php b/includes/libs/objectcache/IStoreKeyEncoder.php
index b7223ef44f7f..b39ec8035dd8 100644
--- a/includes/libs/objectcache/IStoreKeyEncoder.php
+++ b/includes/libs/objectcache/IStoreKeyEncoder.php
@@ -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' );
diff --git a/includes/libs/objectcache/MediumSpecificBagOStuff.php b/includes/libs/objectcache/MediumSpecificBagOStuff.php
index 6d4bd0fe2d95..7530f2602ddd 100644
--- a/includes/libs/objectcache/MediumSpecificBagOStuff.php
+++ b/includes/libs/objectcache/MediumSpecificBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php b/includes/libs/objectcache/MemcachedBagOStuff.php
index 5c208bf7d02e..aab6d412dd98 100644
--- a/includes/libs/objectcache/MemcachedBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/MemcachedPeclBagOStuff.php b/includes/libs/objectcache/MemcachedPeclBagOStuff.php
index 079b5e3b32fa..75159f51c946 100644
--- a/includes/libs/objectcache/MemcachedPeclBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedPeclBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/MemcachedPhpBagOStuff.php b/includes/libs/objectcache/MemcachedPhpBagOStuff.php
index 42c929e0ffe0..6b70dac27de6 100644
--- a/includes/libs/objectcache/MemcachedPhpBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedPhpBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php
index 71deb15cfa48..e6042c05bcd3 100644
--- a/includes/libs/objectcache/MultiWriteBagOStuff.php
+++ b/includes/libs/objectcache/MultiWriteBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/RESTBagOStuff.php b/includes/libs/objectcache/RESTBagOStuff.php
index 23c1c536ac3a..f8efad536226 100644
--- a/includes/libs/objectcache/RESTBagOStuff.php
+++ b/includes/libs/objectcache/RESTBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/RedisBagOStuff.php b/includes/libs/objectcache/RedisBagOStuff.php
index 622d866b4052..6faa2d793a05 100644
--- a/includes/libs/objectcache/RedisBagOStuff.php
+++ b/includes/libs/objectcache/RedisBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/ReplicatedBagOStuff.php b/includes/libs/objectcache/ReplicatedBagOStuff.php
index ad4a9e051de5..72033fe5be64 100644
--- a/includes/libs/objectcache/ReplicatedBagOStuff.php
+++ b/includes/libs/objectcache/ReplicatedBagOStuff.php
@@ -18,6 +18,8 @@
* @file
* @ingroup Cache
*/
+
+use Wikimedia\ObjectCache\BagOStuff;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
diff --git a/includes/libs/objectcache/WinCacheBagOStuff.php b/includes/libs/objectcache/WinCacheBagOStuff.php
index f545d9c0521e..2e67bfbf0ca6 100644
--- a/includes/libs/objectcache/WinCacheBagOStuff.php
+++ b/includes/libs/objectcache/WinCacheBagOStuff.php
@@ -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' );
diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php
index 57244d1ec05b..87e43782e5c5 100644
--- a/includes/libs/objectcache/wancache/WANObjectCache.php
+++ b/includes/libs/objectcache/wancache/WANObjectCache.php
@@ -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
diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php
index 006ca5529954..6f3ae0d4f93c 100644
--- a/includes/libs/rdbms/ChronologyProtector.php
+++ b/includes/libs/rdbms/ChronologyProtector.php
@@ -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.
diff --git a/includes/libs/rdbms/database/DatabaseFactory.php b/includes/libs/rdbms/database/DatabaseFactory.php
index 2f2e9716b4d6..6d5e48ff031f 100644
--- a/includes/libs/rdbms/database/DatabaseFactory.php
+++ b/includes/libs/rdbms/database/DatabaseFactory.php
@@ -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;
/**
diff --git a/includes/libs/rdbms/database/replication/ReplicationReporter.php b/includes/libs/rdbms/database/replication/ReplicationReporter.php
index b92171f999fe..ef44e0a48c2f 100644
--- a/includes/libs/rdbms/database/replication/ReplicationReporter.php
+++ b/includes/libs/rdbms/database/replication/ReplicationReporter.php
@@ -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;
diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php
index 8a8a188d32e4..1768cbab7d3f 100644
--- a/includes/libs/rdbms/lbfactory/LBFactory.php
+++ b/includes/libs/rdbms/lbfactory/LBFactory.php
@@ -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;
diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index 42b94868d008..dd6e7c284b6f 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -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;
/**
diff --git a/includes/libs/rdbms/loadmonitor/ILoadMonitor.php b/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
index bb8efe65e2ba..1092605baa7b 100644
--- a/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
+++ b/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
@@ -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
diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitor.php b/includes/libs/rdbms/loadmonitor/LoadMonitor.php
index 2056d0fd4bb8..7c6c987c566d 100644
--- a/includes/libs/rdbms/loadmonitor/LoadMonitor.php
+++ b/includes/libs/rdbms/loadmonitor/LoadMonitor.php
@@ -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;
diff --git a/includes/linker/LinkTargetStore.php b/includes/linker/LinkTargetStore.php
index 12d674e65d40..2065a9585ae8 100644
--- a/includes/linker/LinkTargetStore.php
+++ b/includes/linker/LinkTargetStore.php
@@ -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;
diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php
index 0f91972638e5..5d8c29d00041 100644
--- a/includes/objectcache/ObjectCache.php
+++ b/includes/objectcache/ObjectCache.php
@@ -22,6 +22,7 @@
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\ObjectCache\BagOStuff;
/**
* @see ObjectCacheFactory
diff --git a/includes/objectcache/ObjectCacheFactory.php b/includes/objectcache/ObjectCacheFactory.php
index 50099f427376..6c096a7c7e31 100644
--- a/includes/objectcache/ObjectCacheFactory.php
+++ b/includes/objectcache/ObjectCacheFactory.php
@@ -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;
/**
diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php
index 66cd79b24302..4cc0e551e3d6 100644
--- a/includes/objectcache/SqlBagOStuff.php
+++ b/includes/objectcache/SqlBagOStuff.php
@@ -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;
diff --git a/includes/page/DeletePage.php b/includes/page/DeletePage.php
index 61fdab2dfdae..24d775b5b59f 100644
--- a/includes/page/DeletePage.php
+++ b/includes/page/DeletePage.php
@@ -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;
diff --git a/includes/page/File/BadFileLookup.php b/includes/page/File/BadFileLookup.php
index 2c426e6c51f0..49bedd374bee 100644
--- a/includes/page/File/BadFileLookup.php
+++ b/includes/page/File/BadFileLookup.php
@@ -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()) */
diff --git a/includes/page/PageCommandFactory.php b/includes/page/PageCommandFactory.php
index 6b7d83b26927..b1f61242c1e0 100644
--- a/includes/page/PageCommandFactory.php
+++ b/includes/page/PageCommandFactory.php
@@ -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;
diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php
index 4c444dc50734..b8d282d7db59 100644
--- a/includes/parser/ParserCache.php
+++ b/includes/parser/ParserCache.php
@@ -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;
diff --git a/includes/parser/ParserCacheFactory.php b/includes/parser/ParserCacheFactory.php
index 6f5718c8178a..cca3fc6c1148 100644
--- a/includes/parser/ParserCacheFactory.php
+++ b/includes/parser/ParserCacheFactory.php
@@ -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;
diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php
index e68d313ff7d3..1dfb16e28943 100644
--- a/includes/registration/ExtensionRegistry.php
+++ b/includes/registration/ExtensionRegistry.php
@@ -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;
/**
diff --git a/includes/registration/MissingExtensionException.php b/includes/registration/MissingExtensionException.php
index 8a05a9749bb8..d5682145b0ac 100644
--- a/includes/registration/MissingExtensionException.php
+++ b/includes/registration/MissingExtensionException.php
@@ -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.
diff --git a/includes/session/PHPSessionHandler.php b/includes/session/PHPSessionHandler.php
index 48266e1dc402..1f67a3b35771 100644
--- a/includes/session/PHPSessionHandler.php
+++ b/includes/session/PHPSessionHandler.php
@@ -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;
/**
diff --git a/includes/session/SessionBackend.php b/includes/session/SessionBackend.php
index 93314a031cdf..eb8e3373271a 100644
--- a/includes/session/SessionBackend.php
+++ b/includes/session/SessionBackend.php
@@ -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.
diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php
index 400da14d1c2b..f2487527bc81 100644
--- a/includes/session/SessionManager.php
+++ b/includes/session/SessionManager.php
@@ -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.
diff --git a/includes/site/CachingSiteStore.php b/includes/site/CachingSiteStore.php
index 9d5526a27fc8..c7fb4dc1ddd2 100644
--- a/includes/site/CachingSiteStore.php
+++ b/includes/site/CachingSiteStore.php
@@ -20,7 +20,7 @@
namespace MediaWiki\Site;
-use BagOStuff;
+use Wikimedia\ObjectCache\BagOStuff;
/**
* Hold a configured list of sites (SiteList), with a caching layer.
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 2fb326dd7714..c9226891a51c 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -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
diff --git a/includes/utils/FileContentsHasher.php b/includes/utils/FileContentsHasher.php
index cbeca3d4c775..fc97fb874550 100644
--- a/includes/utils/FileContentsHasher.php
+++ b/includes/utils/FileContentsHasher.php
@@ -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.
*
diff --git a/includes/watchlist/WatchedItemStore.php b/includes/watchlist/WatchedItemStore.php
index cbe6ba5e5892..56c18f533bfb 100644
--- a/includes/watchlist/WatchedItemStore.php
+++ b/includes/watchlist/WatchedItemStore.php
@@ -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;