Skip to content

Commit

Permalink
Issue #4786 - Set a unique cache ID when filtering current news item.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Jun 3, 2022
1 parent 8198d33 commit 38207a0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions e107_plugins/news/latestnews_menu.php
Expand Up @@ -7,7 +7,17 @@
*/
if (!defined('e107_INIT')) { exit; }

$cacheString = 'nq_news_latest_menu_'.md5(serialize($parm).USERCLASS_LIST.e_LANGUAGE);

if($current = e107::getRegistry('current_news_item'))
{
$currentID = (int) $current['news_id'];
}
else
{
$currentID = 0;
}

$cacheString = 'nq_news_latest_menu_'.md5(serialize($parm).USERCLASS_LIST.e_LANGUAGE.$currentID);
$cached = e107::getCache()->retrieve($cacheString);
if(false === $cached)
{
Expand Down Expand Up @@ -47,9 +57,9 @@
if(vartrue($parms['order'])) $treeparm['db_order'] = e107::getParser()->toDb($parms['order']);
$parms['return'] = true;

if($current = e107::getRegistry('current_news_item'))
if(!empty($currentID))
{
$treeparm['db_where'] = 'news_id != '.(int) $current['news_id'];
$treeparm['db_where'] = 'news_id != '.$currentID;
}

/* Prevent data-overwrite if menu is called within news template and more news shortcodes are called after */
Expand Down

0 comments on commit 38207a0

Please sign in to comment.