Skip to content

Commit

Permalink
fix: avoid error during warmup e.g. new properties on channel
Browse files Browse the repository at this point in the history
  • Loading branch information
delyriand committed Nov 6, 2024
1 parent d11d38a commit df07858
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/CacheWarmer/SettingsCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,31 @@ public function warmUp(string $cacheDir): array
return [];
}

$settings = $this->registry->getAllSettings();
foreach ($settings as $setting) {
$setting->getSettingsByChannelAndLocale();
$setting->getSettingsByChannelAndLocale(null, null, true);
try {
$settings = $this->registry->getAllSettings();
foreach ($settings as $setting) {
$setting->getSettingsByChannelAndLocale();
$setting->getSettingsByChannelAndLocale(null, null, true);

/** @var ChannelInterface $channel */
foreach ($this->channelRepository->findAll() as $channel) {
if (null === $channel->getCode()) {
continue;
}
/** @var ChannelInterface $channel */
foreach ($this->channelRepository->findAll() as $channel) {
if (null === $channel->getCode()) {
continue;
}

$setting->getSettingsByChannelAndLocale($channel);
$setting->getSettingsByChannelAndLocale($channel, null, true);
$setting->getSettingsByChannelAndLocale($channel);
$setting->getSettingsByChannelAndLocale($channel, null, true);

/** @var LocaleInterface $locale */
foreach ($channel->getLocales() as $locale) {
$setting->getSettingsByChannelAndLocale($channel, $locale->getCode());
$setting->getSettingsByChannelAndLocale($channel, $locale->getCode(), true);
/** @var LocaleInterface $locale */
foreach ($channel->getLocales() as $locale) {
$setting->getSettingsByChannelAndLocale($channel, $locale->getCode());
$setting->getSettingsByChannelAndLocale($channel, $locale->getCode(), true);
}
}
}
} catch (\Exception) {
// If an exception is thrown, we just ignore it and return an empty array
// e.g. if upgrade Sylius and a new channel property is added to the ChannelInterface
}

return [];
Expand Down

0 comments on commit df07858

Please sign in to comment.