diff --git a/Echo.php b/Echo.php index ae9346e5e..3d1a68c48 100644 --- a/Echo.php +++ b/Echo.php @@ -70,6 +70,7 @@ $wgAutoloadClasses['EchoUserNotificationGateway'] = $dir . 'includes/gateway/Use // 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 000000000..6ef500308 --- /dev/null +++ b/includes/cache/RevisionLocalCache.php @@ -0,0 +1,68 @@ +lookups ) { + // @Todo Add newFromIds() to Revision + $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__, + array(), + array( + 'page' => Revision::pageJoinCond(), + 'user' => Revision::userJoinCond() + ) + ); + if ( $res ) { + foreach ( $res as $row ) { + $this->targets->set( $row->rev_id, new Revision( $row ) ); + } + $this->lookups = array(); + } + } + } + +} diff --git a/includes/cache/TitleLocalCache.php b/includes/cache/TitleLocalCache.php index ea3558dda..1ca5c5db6 100644 --- a/includes/cache/TitleLocalCache.php +++ b/includes/cache/TitleLocalCache.php @@ -1,5 +1,8 @@ add( $row->event_page_id ); } + if ( isset( $this->extra['revid'] ) && $this->extra['revid'] ) { + $revisionCache = EchoRevisionLocalCache::create(); + $revisionCache->add( $this->extra['revid'] ); + } } /** @@ -428,6 +432,11 @@ class EchoEvent extends EchoAbstractEntity{ if ( $this->revision ) { return $this->revision; } elseif ( isset( $this->extra['revid'] ) ) { + $revisionCache = EchoRevisionLocalCache::create(); + $revision = $revisionCache->get( $this->extra['revid'] ); + if ( $revision ) { + return $this->revision = $revision; + } return $this->revision = Revision::newFromId( $this->extra['revid'] ); } return null;