Skip to content
Snippets Groups Projects
Commit 69d8f0fe authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Account for locale when caching home channels. (#1745)

- Resolves VUFIND-1438.
parent 4b2d5552
No related merge requests found
...@@ -80,6 +80,13 @@ class ChannelLoader ...@@ -80,6 +80,13 @@ class ChannelLoader
*/ */
protected $searchRunner; protected $searchRunner;
/**
* Current locale (used for caching)
*
* @var string
*/
protected $locale;
/** /**
* Constructor * Constructor
* *
...@@ -88,15 +95,18 @@ class ChannelLoader ...@@ -88,15 +95,18 @@ class ChannelLoader
* @param ChannelManager $cm Channel manager * @param ChannelManager $cm Channel manager
* @param SearchRunner $runner Search runner * @param SearchRunner $runner Search runner
* @param RecordLoader $loader Record loader * @param RecordLoader $loader Record loader
* @param string $locale Current locale (used for caching)
*/ */
public function __construct(Config $config, CacheManager $cache, public function __construct(Config $config, CacheManager $cache,
ChannelManager $cm, SearchRunner $runner, RecordLoader $loader ChannelManager $cm, SearchRunner $runner, RecordLoader $loader,
string $locale = ''
) { ) {
$this->config = $config; $this->config = $config;
$this->cacheManager = $cache; $this->cacheManager = $cache;
$this->channelManager = $cm; $this->channelManager = $cm;
$this->searchRunner = $runner; $this->searchRunner = $runner;
$this->recordLoader = $loader; $this->recordLoader = $loader;
$this->locale = $locale;
} }
/** /**
...@@ -211,7 +221,7 @@ class ChannelLoader ...@@ -211,7 +221,7 @@ class ChannelLoader
// Set up the cache, if appropriate: // Set up the cache, if appropriate:
if ($this->config->General->cache_home_channels ?? false) { if ($this->config->General->cache_home_channels ?? false) {
$providerIds = array_map('get_class', $providers); $providerIds = array_map('get_class', $providers);
$parts = [implode(',', $providerIds), $source, $token]; $parts = [implode(',', $providerIds), $source, $token, $this->locale];
$cacheKey = md5(implode('-', $parts)); $cacheKey = md5(implode('-', $parts));
$cache = $this->cacheManager->getCache('object', 'homeChannels'); $cache = $this->cacheManager->getCache('object', 'homeChannels');
} else { } else {
......
...@@ -66,7 +66,8 @@ class ChannelLoaderFactory implements FactoryInterface ...@@ -66,7 +66,8 @@ class ChannelLoaderFactory implements FactoryInterface
$container->get(\VuFind\Cache\Manager::class), $container->get(\VuFind\Cache\Manager::class),
$container->get(\VuFind\ChannelProvider\PluginManager::class), $container->get(\VuFind\ChannelProvider\PluginManager::class),
$container->get(\VuFind\Search\SearchRunner::class), $container->get(\VuFind\Search\SearchRunner::class),
$container->get(\VuFind\Record\Loader::class) $container->get(\VuFind\Record\Loader::class),
$container->get(\Laminas\Mvc\I18n\Translator::class)->getLocale()
); );
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment