12use MediaWiki\MediaWikiServices;
13use Wikimedia\Rdbms\IDatabase;
23 private const CACHE_KEY =
'wikipage';
24 private const CACHE_VERSION = 2;
38 $this->cache = $cache;
41 'key' => self::CACHE_KEY,
42 'version' => self::CACHE_VERSION,
43 'regenerator' => [ $this,
'getCacheData' ],
44 'touchedCallback' => [ $this,
'isExpired' ]
56 if ( $this->groups ===
null ) {
58 $wrapper = $this->cache->getValue();
70 $this->cache->touchKey();
73 $wrapper = $this->cache->getValue(
'recache' );
82 $this->cache->delete();
98 global $wgEnablePageTranslation;
100 $groupTitles = $deps = [];
101 $deps =
new GlobalDependency(
'wgEnablePageTranslation' );
103 if ( $wgEnablePageTranslation ) {
107 $wrapper =
new DependencyWrapper( $groupTitles, $deps );
108 $wrapper->initialiseDeps();
133 public static function getInstance( IDatabase $db =
null, WANObjectCache $cache =
null ) {
135 $db ?? TranslateUtils::getSafeReadDB(),
137 $cache ?? MediaWikiServices::getInstance()->getMainWANObjectCache()
150 $tables = [
'page',
'revtag' ];
151 $vars = [
'page_id',
'page_namespace',
'page_title' ];
152 $conds = [
'page_id=rt_page',
'rt_type' => RevTagStore::TP_MARK_TAG ];
153 $options = [
'GROUP BY' =>
'rt_page,page_id,page_namespace,page_title' ];
154 $res = $this->db->select( $tables, $vars, $conds, __METHOD__, $options );
156 foreach ( $res as $r ) {
157 $title = Title::newFromRow( $r );
158 $groupTitles[] = $title->getPrefixedText();
173 foreach ( $titles as $title ) {
174 $title = Title::newFromText( $title );
175 $id = TranslatablePage::getMessageGroupIdFromTitle( $title );
Mixed bag of methods related to translatable pages.
An abstract class to be implemented by group loaders / stores.
Wrapper around WANObjectCache providing a simpler interface for MessageGroups to use the cache.
configure(array $config)
Configure the message group.
Handles DB operations for Translatable pages, and the related cache.
recache()
Clear and refill the cache with the latest values.
getGroups()
Return the WikiPageMessageGroups If local variable is set, use that otherwise fetch from the cache.
getCacheData()
Get the data that needs to be stored in the cache.
getTranslatablePageTitles()
Fetch page titles marked for translation from the database to store in the cache.
initGroupsFromTitle( $titles)
Convert page titles to WikiPageMessageGroup objects.
static getInstance(IDatabase $db=null, WANObjectCache $cache=null)
Return an instance of this class using the parameters, if passed, else initialize the necessary depen...
clearProcessCache()
Clears the process cache, mainly the cached groups property.
clearCache()
Clear values from the cache.
static registerLoader(array &$groupLoader, array $deps)
Hook: TranslateInitGroupLoaders.
Wraps the translatable page sections into a message group.
To be implemented by MessageGroupLoaders that use the MessageGroupWANCache.