- Issue created by @Ambient.Impact
- 🇨🇦Canada Ambient.Impact Toronto
Added more detail, links to relevant Drupal core and Turbo code, and an example of one hack that seems to work around the issue (though not fixing the underlying problem).
-
Ambient.Impact →
committed d49260b9 on 2.x
Issue #3414538: Added refreshless_turbo_update_10202() to rebuild.
-
Ambient.Impact →
committed d49260b9 on 2.x
-
Ambient.Impact →
committed 9ed32e82 on 2.x
Issue #3414538: refreshless_turbo/js/refreshless.js data-turbo-track="...
-
Ambient.Impact →
committed 9ed32e82 on 2.x
-
Ambient.Impact →
committed 95134ffb on 2.x
Issue #3414538: preprocess: false on refreshless_turbo/js/refreshless.js
-
Ambient.Impact →
committed 95134ffb on 2.x
-
Ambient.Impact →
committed 8ce2c37d on 2.x
refreshless_turbo/js/ajax.js: Merge .use-ajax into once(): This may...
-
Ambient.Impact →
committed 8ce2c37d on 2.x
-
Ambient.Impact →
committed 21ff6396 on 2.x
Issues #3414538 & #3399243: Fix drupalSettingsLoader w/ JS aggregation.
-
Ambient.Impact →
committed 21ff6396 on 2.x
- Status changed to Postponed
4 months ago 12:27am 24 February 2024 - 🇨🇦Canada Ambient.Impact Toronto
Setting to postponed for now; we can clearly state that a known limitation of this Turbo implementation is that JavaScript aggregation should be off or weird things will happen which should be fine for a dev or alpha release; when we start getting to beta, we'll need to implement the longer term proposed resolution in some way.
- 🇬🇧United Kingdom catch
One possibility would be to track $ajax_page_state in session, and then maybe in a middleware, take what's in $_SESSION and fake the query parameter (probably merging with whatever's already in there just in case), then Drupal won't load any of those already-loaded libraries.
- 🇨🇦Canada Ambient.Impact Toronto
That may work, yeah, but I'm wondering if forcing a session for all users - including anonymous users - is going to have a noticeable performance hit. By default, Symfony doesn't start a session until there's something in the session to track (like in this case the Ajax page state) for performance reasons. That said, we do force a session for all users on Omnipedia to track the last few wiki pages a user has visited so that the random page controller knows not to pick something you've just seem, and that seems to perform well enough. If we do start sessions for all users, it would be a good idea to require the core `page_cache` module is uninstalled, because it'll prevent a session being started if a page is already cached - it took me far longer than I would have liked to figure out it was why our random page controller would sometimes redirect to the same page over and over for anonymous users.
- 🇬🇧United Kingdom catch
Might be possible to set it in a cookie instead as well, could still be read in a middleware.
- 🇨🇦Canada Ambient.Impact Toronto
I haven't messed around with any middleware as of yet so I'm not experienced with that but I like the idea. If anyone wants to create a basic prototype I'd be happy to test it out. Sorry about the slow replies; I'm busy with a bunch of stuff at the moment but checking in every so often.
- 🇨🇦Canada Ambient.Impact Toronto
So I tried to implement a solution based on @catch's idea and it sort of works but not quite. It doesn't yet have a cache context to vary by and it breaks Turbo since the Turbo JavaScript isn't found on the page so Turbo does a full page load, and I feel like piggybacking on
ajaxPageState
might not be worth the potential headaches down the road if that changes.To do list/ideas
- Implement a cache context that varies based on a hash or compressed URL query string because we'll likely need to add that to the page
#cache
. - Port over some of the 1.x
refreshless_page_state
logic and don't spoof or useajaxPageState
. - Also don't forget
RefreshlessRenderer::validatePreconditions()
for security from the 1.x branch. - Turbo and RefreshLess stuff needs to be handled separately and excluded from being removed on subsequent pages because doing so causes Turbo to relinquish control and let a full page load occur. We may have to decorate another one of the core asset services to group the RefreshLess and Turbo stuff into its own aggregate since setting it all to
preprocess: false
isn't great. - Implement the PHP logic somewhere to exclude the already loaded libraries somewhere; our decorated
AssetResolver
would make the most sense since it's central to the whole process.
Core stuff to use as reference
- Implement a cache context that varies based on a hash or compressed URL query string because we'll likely need to add that to the page