mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
Merge "EventPresentationModel: Cache the result of getBundledEvents()"
This commit is contained in:
commit
a8171d1f75
|
@ -27,6 +27,11 @@ abstract class EchoEventPresentationModel {
|
||||||
*/
|
*/
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var EchoEvent[]|null
|
||||||
|
*/
|
||||||
|
private $bundledEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param EchoEvent $event
|
* @param EchoEvent $event
|
||||||
* @param Language|string $language
|
* @param Language|string $language
|
||||||
|
@ -88,17 +93,20 @@ abstract class EchoEventPresentationModel {
|
||||||
if ( !$this->event->getBundleHash() ) {
|
if ( !$this->event->getBundleHash() ) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
if ( $this->bundledEvents !== null ) {
|
||||||
|
return $this->bundledEvents;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: We really shouldn't be making db queries like this
|
// FIXME: We really shouldn't be making db queries like this
|
||||||
// in the presentation model
|
// in the presentation model
|
||||||
$eventMapper = new EchoEventMapper();
|
$eventMapper = new EchoEventMapper();
|
||||||
$events = $eventMapper->fetchByUserBundleHash(
|
$this->bundledEvents = $eventMapper->fetchByUserBundleHash(
|
||||||
$this->user,
|
$this->user,
|
||||||
$this->event->getBundleHash()
|
$this->event->getBundleHash()
|
||||||
// default params: web, DESC, limit=250
|
// default params: web, DESC, limit=250
|
||||||
);
|
);
|
||||||
|
|
||||||
return $events;
|
return $this->bundledEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue