mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-14 19:14:45 +00:00
Remove use of Revision::newFromTitle
Bug: T249183 Change-Id: Ibfcb8d7e56f559f3fb5179bac4dfeade8da22533
This commit is contained in:
parent
f7e1b0e282
commit
3f00fbb5aa
|
@ -2,6 +2,8 @@
|
|||
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionLookup;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use Wikimedia\Rdbms\Database;
|
||||
|
||||
/**
|
||||
|
@ -21,8 +23,15 @@ class GadgetDefinitionNamespaceRepo extends GadgetRepo {
|
|||
*/
|
||||
private $wanCache;
|
||||
|
||||
/**
|
||||
* @var RevisionLookup
|
||||
*/
|
||||
private $revLookup;
|
||||
|
||||
public function __construct() {
|
||||
$this->wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$this->wanCache = $services->getMainWANObjectCache();
|
||||
$this->revLookup = $services->getRevisionLookup();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,13 +118,13 @@ class GadgetDefinitionNamespaceRepo extends GadgetRepo {
|
|||
return null;
|
||||
}
|
||||
|
||||
$rev = Revision::newFromTitle( $title );
|
||||
if ( !$rev ) {
|
||||
$revRecord = $this->revLookup->getRevisionByTitle( $title );
|
||||
if ( !$revRecord ) {
|
||||
$ttl = WANObjectCache::TTL_UNCACHEABLE;
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = $rev->getContent();
|
||||
$content = $revRecord->getContent( SlotRecord::MAIN );
|
||||
if ( !$content instanceof GadgetDefinitionContent ) {
|
||||
// Uhm...
|
||||
$ttl = WANObjectCache::TTL_UNCACHEABLE;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use Wikimedia\Rdbms\Database;
|
||||
|
||||
/**
|
||||
|
@ -136,12 +137,17 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
|
|||
if ( $forceNewText === null ) {
|
||||
// T157210: avoid using wfMessage() to avoid staleness due to cache layering
|
||||
$title = Title::makeTitle( NS_MEDIAWIKI, 'Gadgets-definition' );
|
||||
$rev = Revision::newFromTitle( $title );
|
||||
if ( !$rev || !$rev->getContent() || $rev->getContent()->isEmpty() ) {
|
||||
$revRecord = MediaWikiServices::getInstance()
|
||||
->getRevisionLookup()
|
||||
->getRevisionByTitle( $title );
|
||||
if ( !$revRecord
|
||||
|| !$revRecord->getContent( SlotRecord::MAIN )
|
||||
|| $revRecord->getContent( SlotRecord::MAIN )->isEmpty()
|
||||
) {
|
||||
return false; // don't cache
|
||||
}
|
||||
|
||||
$g = $rev->getContent()->getNativeData();
|
||||
$g = $revRecord->getContent( SlotRecord::MAIN )->getNativeData();
|
||||
} else {
|
||||
$g = $forceNewText;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue