mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
ef50bfeda5
Singletons are bad, amongst other reasons, because they're never reset in tests. They can therefore occasionally cause test failures if the cached data stored in one of these singletons becomes stale. As noted on the task, ideally these two classes shouldn't exist at all, and core should be responsible for caching the information it deems expensive to compute. As a temporary (TM) workaround, make both classes actual services, so that the setUp/tearDown logic in MediaWikiIntegrationTestCase can properly reset them between tests. Dependencies are intentionally not being injected, precisely because these classes should just be deleted, not improved. Bug: T344124 Change-Id: I58b8d9610f9447468235b94d25732528ab6acce6
32 lines
751 B
PHP
32 lines
751 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Cache;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
/**
|
|
* Cache class that maps revision id to RevisionStore object
|
|
* @xxx Like TitleLocalCache, this class shouldn't need to exist.
|
|
*/
|
|
class RevisionLocalCache extends LocalCache {
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
protected function resolve( array $lookups ) {
|
|
$store = MediaWikiServices::getInstance()->getRevisionStore();
|
|
$dbr = wfGetDB( DB_REPLICA );
|
|
$revQuery = $store->getQueryInfo( [ 'page', 'user' ] );
|
|
$res = $dbr->select(
|
|
$revQuery['tables'],
|
|
$revQuery['fields'],
|
|
[ 'rev_id' => $lookups ],
|
|
__METHOD__,
|
|
[],
|
|
$revQuery['joins']
|
|
);
|
|
foreach ( $res as $row ) {
|
|
yield $row->rev_id => $store->newRevisionFromRow( $row );
|
|
}
|
|
}
|
|
}
|