mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-09 23:56:11 +01:00
Do not break performance when no postponed date exists
Some sites do not use postponed_date at all. It would be a massive performance issue to still search for them for each and every date instance that is created. This small addition will solve the issue for those pages. It will still once at least one internal reference is added. We could then try to add proxies which are build and added, but don't use the DB. That way the performance would still be okay, and data will only be fetched when used.
This commit is contained in:
parent
8816eca99e
commit
d0cb951550
1 changed files with 16 additions and 1 deletions
|
@ -38,17 +38,32 @@ class AddSpecialProperties
|
|||
*/
|
||||
private $dataMapper;
|
||||
|
||||
/**
|
||||
* Internal info to speed things up if we know there are none.
|
||||
* @var bool
|
||||
*/
|
||||
private $doPostponedDatesExist = true;
|
||||
|
||||
public function __construct(
|
||||
ConnectionPool $connectionPool,
|
||||
DataMapper $dataMapper
|
||||
) {
|
||||
$this->connectionPool = $connectionPool;
|
||||
$this->dataMapper = $dataMapper;
|
||||
|
||||
$qb = $this->connectionPool->getQueryBuilderForTable('tx_events_domain_model_date');
|
||||
$qb->count('uid');
|
||||
$qb->from('tx_events_domain_model_date');
|
||||
$qb->where($qb->expr()->gt('postponed_date', $qb->createNamedParameter(0)));
|
||||
$this->doPostponedDatesExist = $qb->execute()->fetchColumn() > 0;
|
||||
}
|
||||
|
||||
public function __invoke(AfterObjectThawedEvent $event): void
|
||||
{
|
||||
if ($event->getObject() instanceof Date) {
|
||||
if (
|
||||
$this->doPostponedDatesExist
|
||||
&& $event->getObject() instanceof Date
|
||||
) {
|
||||
/** @var Date $date */
|
||||
$date = $event->getObject();
|
||||
$date->_setProperty('originalDate', $this->getOriginalDate($date->_getProperty('_localizedUid')));
|
||||
|
|
Loading…
Reference in a new issue