- Issue created by @effulgentsia
- π¬π§United Kingdom catch
The idea is to only convert auto-saved states to real draft revisions when someone goes looking for those revisions.
This is very sneaky and I like it.
- πΊπΈUnited States tedbow Ithaca, NY, USA
UPDATE: my comment below goes on the assumption that we would using
hook_entity_query_alter
but since @effulgentsia mentionedhasData()
we would need to use something likehook_query_alter
so maybe this won't be done on the entity query level but the lower level which probably means there would be less edge cases.Original comment
By `hook_query_entity_query_alter` do you mean `hook_entity_query_alter`?
?
Does that get triggered for the node x when viewing node/X? I test but didn't seem to for me? Does it get triggered for views? I would have thought so but in debugging it didn't seems to(I did see some hits for that hook).
Could we reliably use just entity query altering? Would we have to implement
hook_entity_preload
and make sure ours runs after `workspaces_entity_preload
`?Would we have to implement `hook_views_query_alter` also? Since workspaces `\Drupal\workspaces\ViewsQueryAlter::alterQuery` seems to have. Otherwise the filters would not work correctly on a View, right?
I like the idea in theory I like the idea but I wonder if we end playing whack-a-mole to have all the places we need lazy load our entities before.
but maybe looking at all the hooks in
workspaces.module
all the works has already been done for a lot of these problem because Workspaces needs for instance make sure the right revision is used inworkspaces_entity_preload
, so in that case we would also need to check if there is an auto-save state. - πΊπΈUnited States effulgentsia
By `hook_query_entity_query_alter` do you mean `hook_entity_query_alter`?
I think I mean the former. Or in other words,
hook_query_TAG_alter()
, whereentity_query
is the TAG.Just to be clear though, I'm not suggesting to actually alter the query. I'm suggesting instead that before the query is executed, that we invoke the code to save auto-saved states into revisions, and then let the original query proceed as normal.
Not sure yet about how much that will cover vs. needing additional hooks to also trigger the revision creations.
- πΊπΈUnited States tedbow Ithaca, NY, USA
-
Just to be clear though, I'm not suggesting to actually alter the query. I'm suggesting instead that before the query is executed, that we invoke the code to save auto-saved states into revisions, and then let the original query proceed as normal.
'
Yep I got that. I think we would also have to do this onhook_entity_preload()
has that appears to not result in a query uses the `entity_query
` Instead it uses this$query->addTag($this->entityTypeId . '_load_multiple');
. -
I think we could do first try at this that implements
hook_entity_preload()
,hook_views_query_alter
andhook_query_TAG_alter
we know might miss some edge cases where the system query the tables on a lower level but then work from there.We could keep of track of the ids of the entities that have auto-save states in the current workspace and if a query might return those entities then when convert the auto-saves to real revisions. We could see how the performance and then make the system better if need be. For example we could determine which bundles currently have auto-save states and inspect queries to see if they filter by bundle and will not return the bundles that auto-saves and then we know we don't need to do any conversions
-
Since the above ideas all have their shortfalls, instead I recommend an on-demand revision creation approach
(emphasis mine)
While I see the benefit of the lazy saving approach I don't see how it can replace saving revisions every once in a while.For instance if 1 user is working on page in XB for many hours and nobody else is viewing the workspace then we would never make a revision of that page and then the history would be lost. I guess that won't be true if β¨ Implement time travel (undo/redo/revert) of auto-saved states across devices and users Active is done without relying revisions at all(I am not convinced of that, are the any UI mock-ups for going through hundreds or thousands of auto-save states?)
So the this lazy-saving has to be an add-on functionality to solve the problem of seeing the workspace with the very latest XB changes, it doesn't help keeping a history, at least it can't be relied on for that
-