OFFLINE-GmbH / oc-boxes-support

This repo is used for support requests for the OFFLINE.Boxes plugin
https://boxes.offline.ch
4 stars 0 forks source link

I can no longer access or edit content in the boxes editor on multi-site pages #119

Closed roojai closed 6 months ago

roojai commented 7 months ago

Describe the bug I have made no changes to my site other than updating the OctoberCMS version and also the Boxes version and now I cannot access content within the pages editor for multisites. If I select the main site, all is fine and I can access content in the boxes plugin editor, but as soon as I change site to another of the multi-sites, then I get a 404 in the boxes editor. On the frontend, all is fine, the multi-sites work ok.

I simply can no longer edit them.

Is this something to do with the "Page on the main site" functionality - as before we did not have this?

FYI, I use the multi-site to show completely different content, with different URLs, I do dot use it for language variations

Boxes Version v3.6.1

image

image

tobias-kuendig commented 7 months ago

@roojai I cannot reproduce the issue right away. Would it be possible for you to provide me the offlineboxes* tables from your database? You can e-mail them to me.

tobias-kuendig commented 7 months ago

Thank you for providing me with a db dump. Switching sites works on my end. Can you confirm that you have no component on the page that triggers the 404 redirect (like an {% abort(404) %} in Twig or a return $this->controller->run(404); in a php component?

Also, how do you differentiate your sites? Are you using an URL prefix or a different hostname per site? It is possible that Boxes does not catch that for some reason.

If you want to debug the issue on your end, the problem is problably here: https://github.com/OFFLINE-GmbH/oc-boxes-free-plugin/blob/584ef04107d6da8c913928a037d25f75ff731366/Plugin.php#L100

roojai commented 6 months ago

Hi Tobias,

OK, I did some debugging.

image

This always returns my main site, it does not return the active site.

image

When I load a page, it seems to call this function twice: image

So I forced the site to the correct site: image

Now I get the correct site in the log, but still have the same issue, it does not resolve the problem,

image

On Tue, 16 Apr 2024 at 21:03, Tobias Kündig @.***> wrote:

Thank you for providing me with a db dump. Switching sites works on my end. Can you confirm that you have no component on the page that triggers the 404 redirect (like an {% abort(404) %} in Twig or a return $this->controller->run(404); in a php component?

Also, how do you differentiate your sites? Are you using an URL prefix or a different hostname per site? It is possible that Boxes does not catch that for some reason.

If you want to debug the issue on your end, the problem is problably here:

https://github.com/OFFLINE-GmbH/oc-boxes-free-plugin/blob/584ef04107d6da8c913928a037d25f75ff731366/Plugin.php#L100

  • it might not resolve the right site
  • the prefix is handled wrong
  • the getPreviewPage method call probably returns null which results in a 404.

— Reply to this email directly, view it on GitHub https://github.com/OFFLINE-GmbH/oc-boxes-support/issues/119#issuecomment-2059039975, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHN2MTJAJGDDSPI7Z7EMHATY5UORBAVCNFSM6AAAAABGHI6CMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJZGAZTSOJXGU . You are receiving this because you were mentioned.Message ID: @.***>

tobias-kuendig commented 6 months ago

Thank you @roojai! I was able to find the culprit: Boxes stores the Theme with every page and only fetches pages from the active theme.

Since October does not change the Site context in the backend (and therefore sets the new active theme), we have to work around this.

Please give v3.6.8 a try and let me know if the issue is solved.

roojai commented 6 months ago

Thanks @tobias-kuendig

I tried v 3.6.8 and its a lot better (can see the preview content now).

However its not quite as before the issue arose.

My site has different CSS and different partials between site versions, but when on another site the previewer is showing CSS from main site, and some partials seem to be the wrong version. I need to investigate further if these are using the same file names or not. The multisite sis work fine before whatever changed.

tobias-kuendig commented 6 months ago

the previewer is showing CSS from main site

I'll take another look at it. It seems like the theme is not switched to the Site's theme override properly.

The multisite sis work fine before whatever changed.

This is probably because the displayed 404 page was being shown with the proper theme.

tobias-kuendig commented 6 months ago

@roojai, please give v3.6.9 a go.

roojai commented 6 months ago

Thanks for trying! If I have partials with the same name in different multi-sites, the previewer loads the version from the mainsite, and not the active site

In addition, I have some data in the theme settings for each site, which I access like this for example:

$theme = Theme::getActiveTheme(); $themeData = ThemeData::forTheme($theme); $themecolors = $themeData->getAttribute('themecolours');

the boxes preview uses the data from the main site, and not the active site.

tobias-kuendig commented 6 months ago

@roojai, please give v3.6.10 another try.

roojai commented 6 months ago

That's fixed it, great work! Thanks @tobias-kuendig

tobias-kuendig commented 6 months ago

Great to hear, thank you for your patience!