-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Preview link when no locale set #861
FIX Preview link when no locale set #861
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to feel really flaky.
I've done a root cause analysis and this PR is what causes the problem that results in needing this "temp locale" in the first place.
This fixes it without needing a temp locale:
public function updatePreviewLink(&$link): void
{
$owner = $this->owner;
- $info = $owner->LocaleInformation(FluentState::singleton()->getLocale());
+ $locale = FluentState::singleton()->getLocale();
+ if ($locale === null || $locale === '') {
+ return;
+ }
+ $info = $owner->LocaleInformation($locale);
if (!$info->getSourceLocale()) {
$link = null;
}
}
With this change, if there is no current locale (i.e. locales haven't been set up yet) it won't update the preview URL. It'll only update it when there is a current locale (i.e. locales have been set up).
d5183c4
to
713786b
Compare
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly yes, looks like the previous CI failure was actually just from rendering the preview link from a template. Reverted as second commit, so do not squash merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue silverstripe/.github#272
Fixes vendor/silverstripe/cms/tests/behat/features/preview-a-page.feature:12 - which breaks when silverstripe/recipe-kitchen-sink is run including silverstripe/cms behat tests.
The issue that behat is running into is that the preview link will not show anything as no locale has been defined in a behat context