Page MenuHomePhabricator

Add namespace to ObjectCache (BagOStuff and friends) library
Open, Needs TriagePublic

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.
  • 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
  • Migrate classes into new namespace, add aliases for backwards-compatibility
  • Migrate MediaWiki core to use the new class names

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=