Bsitu has uploaded a new change for review. https://gerrit.wikimedia.org/r/154387
Change subject: [5] Add revision local cache holder object ...................................................................... [5] Add revision local cache holder object Change-Id: I85f68b3ca269c711a8a177e013bd8eba38833444 --- M Echo.php A includes/cache/RevisionLocalCache.php 2 files changed, 57 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/87/154387/1 diff --git a/Echo.php b/Echo.php index ae9346e..3d1a68c 100644 --- a/Echo.php +++ b/Echo.php @@ -70,6 +70,7 @@ // Local caches $wgAutoloadClasses['EchoLocalCache'] = $dir . 'includes/cache/LocalCache.php'; $wgAutoloadClasses['EchoTitleLocalCache'] = $dir . 'includes/cache/TitleLocalCache.php'; +$wgAutoloadClasses['EchoRevisionLocalCache'] = $dir . 'includes/cache/RevisionLocalCache.php'; // Output formatters $wgAutoloadClasses['EchoDataOutputFormatter'] = $dir . 'includes/DataOutputFormatter.php'; diff --git a/includes/cache/RevisionLocalCache.php b/includes/cache/RevisionLocalCache.php new file mode 100644 index 0000000..a584ffd --- /dev/null +++ b/includes/cache/RevisionLocalCache.php @@ -0,0 +1,56 @@ +<?php + +class EchoRevisionLocalCache extends EchoLocalCache { + + /** + * @var EchoRevisionLocalCache + */ + private static $instance; + + /** + * Use EchoRevisionLocalCache::create() + */ + private function __construct() {} + + /** + * Create a EchoRevisionLocalCache object + * @return EchoRevisionLocalCache + */ + public static function create() { + if ( !self::$instance ) { + self::$instance = new EchoRevisionLocalCache(); + } + return self::$instance; + } + + /** + * {@inheritDoc} + */ + protected function resolve() { + if ( $this->lookups ) { + // @Todo Make a core Revision::newFromIds() + $dbr = wfGetDB( DB_SLAVE ); + $fields = array_merge( + Revision::selectFields(), + Revision::selectPageFields(), + Revision::selectUserFields() + ); + $res = $dbr->select( + array( 'revision', 'page', 'user' ), + $fields, + array( 'rev_id' => $this->lookups ), + __METHOD__, + $options, + array( 'page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond() ) + ); + if ( $res ) { + foreach ( $res as $row ) { + $this->targets[$row->rev_id] = new Revision( $row ); + } + } + + $this->lookups = array(); + } + } + +} -- To view, visit https://gerrit.wikimedia.org/r/154387 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I85f68b3ca269c711a8a177e013bd8eba38833444 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Bsitu <bs...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits