Skip to content

Commit

Permalink
Do not double tag the content elements
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Dec 9, 2020
1 parent 64c4cdc commit 4b61ac2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 78 deletions.
15 changes: 2 additions & 13 deletions calendar-bundle/src/Resources/contao/classes/Events.php
Expand Up @@ -281,21 +281,10 @@ protected function addEvent($objEvents, $intStart, $intEnd, $intBegin, $intLimit
}
}

// Tag the event and its child content elements (see #2137). Calendars
// will be tagged separately in the related front end modules.
// Tag the event (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array('contao.db.tl_calendar_events.' . $objEvents->id);

if ($objElements = ContentModel::findPublishedByPidAndTable($objEvents->id, 'tl_calendar_events'))
{
foreach ($objElements as $objElement)
{
$arrTags[] = 'contao.db.tl_content.' . $objElement->id;
}
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_calendar_events.' . $objEvents->id));
}

// Store raw data
Expand Down
12 changes: 2 additions & 10 deletions calendar-bundle/src/Resources/contao/modules/ModuleCalendar.php
Expand Up @@ -71,18 +71,10 @@ public function generate()
return '';
}

// Add a response tag for every calendar (see #2137). Events and content
// elements will be tagged automatically in the getAllEvents() method.
// Tag the calendars (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array();

foreach ($this->cal_calendar as $id)
{
$arrTags[] = 'contao.db.tl_calendar.' . $id;
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_calendar.' . $id; }, $this->cal_calendar));
}

$this->strUrl = preg_replace('/\?.*$/', '', Environment::get('request'));
Expand Down
14 changes: 2 additions & 12 deletions calendar-bundle/src/Resources/contao/modules/ModuleEventReader.php
Expand Up @@ -237,20 +237,10 @@ protected function compile()
$objTemplate->hasDetails = false;
$objTemplate->hasTeaser = false;

// Tag the event and its child content elements (see #2137)
// Tag the event (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array('contao.db.tl_calendar_events.' . $objEvent->id);

if ($objElements = ContentModel::findPublishedByPidAndTable($objEvent->id, 'tl_calendar_events'))
{
foreach ($objElements as $objElement)
{
$arrTags[] = 'contao.db.tl_content.' . $objElement->id;
}
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_calendar_events.' . $objEvent->id));
}

// Clean the RTE output
Expand Down
12 changes: 2 additions & 10 deletions calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php
Expand Up @@ -77,18 +77,10 @@ public function generate()
return $this->getFrontendModule($this->cal_readerModule, $this->strColumn);
}

// Add a response tag for every calendar (see #2137). Events and content
// elements will be tagged automatically in the getAllEvents() method.
// Tag the calendars (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array();

foreach ($this->cal_calendar as $id)
{
$arrTags[] = 'contao.db.tl_calendar.' . $id;
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_calendar.' . $id; }, $this->cal_calendar));
}

return parent::generate();
Expand Down
15 changes: 2 additions & 13 deletions news-bundle/src/Resources/contao/modules/ModuleNews.php
Expand Up @@ -222,21 +222,10 @@ protected function parseArticle($objArticle, $blnAddArchive=false, $strClass='',
}
}

// Tag the news and its child content elements (see #2137). News archives
// will be tagged separately in the related front end modules.
// Tag the news (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array('contao.db.tl_news.' . $objArticle->id);

if ($objElements = ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news'))
{
foreach ($objElements as $objElement)
{
$arrTags[] = 'contao.db.tl_content.' . $objElement->id;
}
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_news.' . $objArticle->id));
}

return $objTemplate->parse();
Expand Down
12 changes: 2 additions & 10 deletions news-bundle/src/Resources/contao/modules/ModuleNewsArchive.php
Expand Up @@ -73,18 +73,10 @@ public function generate()
return '';
}

// Add a response tag for every news archive (see #2137). News and content
// elements will be tagged automatically in the parseArticles() method.
// Tag the news archives (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array();

foreach ($this->news_archives as $id)
{
$arrTags[] = 'contao.db.tl_news_archive.' . $id;
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_news_archive.' . $id; }, $this->news_archives));
}

return parent::generate();
Expand Down
12 changes: 2 additions & 10 deletions news-bundle/src/Resources/contao/modules/ModuleNewsList.php
Expand Up @@ -66,18 +66,10 @@ public function generate()
return $this->getFrontendModule($this->news_readerModule, $this->strColumn);
}

// Add a response tag for every news archive (see #2137). News and content
// elements will be tagged automatically in the parseArticles() method.
// Tag the news archives (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$arrTags = array();

foreach ($this->news_archives as $id)
{
$arrTags[] = 'contao.db.tl_news_archive.' . $id;
}

System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags);
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_news_archive.' . $id; }, $this->news_archives));
}

return parent::generate();
Expand Down

0 comments on commit 4b61ac2

Please sign in to comment.