silverstripe/silverstripe-subsites

Subsites + Fluent = incorrect URL segment on edit

Opened this issue · 10 comments

I initially raised this over on the SilverStripe forums, but haven't had any luck there, so giving it a go here.

Version: Silverstripe CWP 2.1.1 (GitHub - silverstripe/cwp-installer: CWP project template)

When using Fluent in tandem with Subsites, the URLSegment shown on any subsite edit page uses the wrong base domain (making it difficult for the editor to open the page in another tab).

e.g. here’s the page without Fluent installed, showing the correct URL:

de0d0cbc9198fec3b65cebeddc386a1c0b7f81cc

…but if I add Fluent to my build, we get this…

79fa97064e8cff2e45c541e8338368db390b47c9

Any suggestions/ideas as to get the correct URL segment to show in that context?

Assuming "main.localhost" is NOT the configured domain for your "Subsite" subsite, and your screenshots are in the reverse order (the first is with fluent installed and the second is without), then I think there's a bug in fluent + subsites compatibility, probably in the DetectLocaleMiddleware, and we can investigate. Can you confirm my assumptions please?

Ah, yes, sorry - uploaded images in the wrong order. (Fixed).

And yes, it does appear to be directly related to fluent + subsites. Any insights welcome.

Is this affecting the URL segment preview in the CMS only? Or the frontend website as well?

Just the CMS. Front-end is fine.

(Although, having said that, we haven't added any translated content to the site yet, so the translated versions of those pages - and specifically the way the URL segments are generated - are currently an unknown quantity.)

Reproduced using CWP 2.3.x-dev (SilverStripe 4.4.x-dev with Subsites 2.3.x-dev and Fluent 4.2.x-dev).

Yeah this is a priority issue with Fluent, where both SiteTreeSubsites and FluentSiteTreeExtension are setting $urlSegmentField->setURLPrefix($baseURL) and the $baseURL respectively is either the subsite domain or the fluent domain configuration.

Both subsites and fluent provide the ability to define domains, so I suppose this is overlapping and conflicting functionality, where at the moment Fluent is taking priority.

I think the issue here is with Fluent, not with Subsites. Subsites sets the URL segment field's prefix to be the subsite domain, and when Fluent does the same thing it sets the URL prefix to be the Director::absoluteBaseURL(), which is the current domain you're on. Since subsites doesn't switch to subsite domains when you're editing non-default subsite content, that URL is always the main domain's URL. If Fluent used the exisiting value for the URL segment field prefix instead of defaulting to Director::absoluteBaseURL() then it would respect both the subsite domain and the fluent locale in the URL segment.

Note: if you configure subsite domains AND fluent domains, you'll still have a conflict here. I think the way to fix this right now is to document it clearly, which I'll include in this story.

Fixed in fluent with tractorcow-farm/silverstripe-fluent#523. I've also made a docs PR at #418.

Thanks Robbie - much appreciated.

No problem, this will be available in the next fluent 4.2.x or newer release. You can pull in 4.2.x-dev for now if you want the fix sooner.

Unfortunately the fix in Fluent has been reverted. I'll reopen this until we can solve it (again).