Page MenuHomePhabricator

Add namespace to BagOStuff library (ObjectCache, MemcachedClient, Redis)
Open, LowPublic

Description

The BagOStuff and other classes that extend it are defined in the global namespace, stored in includes/libs/objectcache folder.
When working on T353458, I tried to move some of the BagOStuff classes and discovered that some things in objectcache/utils folder already belong to Wikimedia/LightweightObjectStore namespace.

Let's decide on the namespace and what to do with existing namespaced classes.

Definition of done

  • Agree on the namespace name Wikimedia/ObjectCache to match folder structure, or Wikimedia/LightweightObjectStore to match the namespace of some classes.
  • Migrate classes into new namespace, add aliases for backwards-compatibility
  • Migrate MediaWiki core to use the new class names
  • decide on what to do with items in Wikimedia/LightweightObjectStore namespace - move to Wikimedia/{NEW_NAME}/Utils namespace, or move files to lib root directory

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Krinkle do you have any thoughts on this? Do you know where the Wikimedia/LightweightObjectStore comes from?

LightweightObjectStore was introduced as a draft namespace for internal BagOStuff-related classes. It became obvious that adding things like "ExpirationAwareness" as a global unnamespaced class would be far too generic, so we picked a namespace.

However, I don't think it's a brandable library name, and too verbose for my taste if we're going to publish it properly. I'd recommend going with Wikimedia\BagOStuff instead. The ones already there may be obsolete or things we can rename with a class_alias.

It has very little use in practice, and for the most part, it seems more appropiate for these references to use $cache::TTL_ or BagOStuff::TTL_ instead, following the principal of locality in terms of getting constants from the thing you link with, instead of from some shared internal trait.

https://codesearch.wmcloud.org/deployed/?q=%28ExpirationAwareness%7CStorageAwareness%29%3A%3A&files=php%24&excludeFiles=test&repos=

Change #1083488 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] objectcache: Move RedisConnRef.php to /libs/objectcache/

https://gerrit.wikimedia.org/r/1083488

Krinkle renamed this task from Add namespace to ObjectCache (BagOStuff and friends) library to Add namespace to BagOStuff library (ObjectCache, MemcachedClient, Redis).Oct 28 2024, 3:31 AM
Krinkle triaged this task as Low priority.
Krinkle updated the task description. (Show Details)
Task description:

decide on what to do with items in Wikimedia/LightweightObjectStore namespace

The /lib/objectcache/utils/ directory contains these two differently-namespaced classes:

Change #1083488 merged by jenkins-bot:

[mediawiki/core@master] objectcache: Move RedisConnRef.php to /libs/objectcache/

https://gerrit.wikimedia.org/r/1083488

Change #1106562 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] objectcache: Move internal StorageAwareness to ObjectCache namespace

https://gerrit.wikimedia.org/r/1106562

Change #1106563 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] objectcache: Tag SerializedValueContainer as `@internal`

https://gerrit.wikimedia.org/r/1106563

Change #1106564 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] objectcache: Move RedisConn files out of utils/ to match class

https://gerrit.wikimedia.org/r/1106564

Change #1106562 merged by jenkins-bot:

[mediawiki/core@master] objectcache: Move internal StorageAwareness to ObjectCache namespace

https://gerrit.wikimedia.org/r/1106562

Change #1106563 merged by jenkins-bot:

[mediawiki/core@master] objectcache: Tag SerializedValueContainer as `@internal`

https://gerrit.wikimedia.org/r/1106563

Change #1106564 merged by jenkins-bot:

[mediawiki/core@master] objectcache: Move RedisConn files out of utils/ to match class

https://gerrit.wikimedia.org/r/1106564

Change #1110876 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] Remove use of BagOStuff TTL constants from unrelated code

https://gerrit.wikimedia.org/r/1110876

Change #1110877 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] Storage,MessageCache: Reference TTL constants from BagOStuff

https://gerrit.wikimedia.org/r/1110877

Change #1110879 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/GrowthExperiments@master] Un-implement ExpirationAwareness

https://gerrit.wikimedia.org/r/1110879

Change #1110879 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Un-implement ExpirationAwareness

https://gerrit.wikimedia.org/r/1110879

Change #1110876 merged by jenkins-bot:

[mediawiki/core@master] Remove use of BagOStuff TTL constants from unrelated code

https://gerrit.wikimedia.org/r/1110876

Change #1110877 merged by jenkins-bot:

[mediawiki/core@master] Storage,MessageCache: Reference TTL constants from BagOStuff

https://gerrit.wikimedia.org/r/1110877

Change #1126155 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] objectcache: Remove internal StorageAwareness, now unused

https://gerrit.wikimedia.org/r/1126155

Change #1072920 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/CentralAuth@master] Replace ExpirationAwareness with BagOStuff

https://gerrit.wikimedia.org/r/1072920

Change #1072920 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Replace ExpirationAwareness with BagOStuff

https://gerrit.wikimedia.org/r/1072920

Change #1126155 merged by jenkins-bot:

[mediawiki/core@master] objectcache: Remove internal StorageAwareness, now unused

https://gerrit.wikimedia.org/r/1126155

Note LightweightObjectStore was mostly going to be used in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/524663/27 . Any such interfaces can just use the ObjectCache namespace.

For better or for worse, it looks like there are still a number of extensions that currently reference (the now-@internal) ExpirationAwareness directly (https://codesearch.wmcloud.org/things/?q=ExpirationAwareness currently returns 39 files from 25 repositories).