Repository navigation
Conversation
|
Size Change: +4 B (0%) Total Size: 7.82 MB 📦 View Changed
|
|
Flaky tests detected in d05616f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31167450860 preserves content in the Custom HTML block in
|
|
I would like to understand the reasoning more. from a core-data perspective, saving a tag should invalidate the cache because the current lists are going to be outdated anyway, so in that sense the current behavior is correct. Maybe what you need here is to wrap multiple action calls in "registry.batch" and have the registry only do the cache invalidation after the batch (don't know if that behavior is built-in or not). |
|
Thanks for the comment, Riad! The term example isn't really a good one; I've only mentioned it because that's what led me to this exploration. At the moment, I'm not sure whether I should use that option. Depends on refactoring in #80967. The current default behavior is correct for most cases, and that's why it remains. I think this is more about giving consumers the freedom to opt out of cache invalidation. I need to experiment with Quick Edit in DataViews and see if there's an actual win. |
tyxla
left a comment
There was a problem hiding this comment.
One thing to consider is that this option moves cache consistency from core-data to each consumer. That way any consumer can disable invalidation and accidentally leave lists, ordering, or pagination out of date. I guess if we choose to keep this option, we should clearly define how callers invalidate the cache later and clearly document their responsibility.
That should be expected since the consumer intentionally opts out. We could provide an action to easily invalidate entity collections; currently, you have to loop through the P.S. It was interesting to learn that |
I can see how that can be missed regardless, and that's my biggest worry. Especially considering that everyone shares this data and plugin X can harm plugin Y without realizing. |
We should be using the stale-while-revalidate (SWR) pattern here. Creating a tag invalidates the old list, but most of the time, it's desirable that the selectors still return the old list instead of If we don't do this SWR pattern correctly, that's almost a bug, we should fix that. Let's use TanStack Query as an inspiration whenever possible. They have all this solved very elegantly, hard to come up with something better. When TanStack Query does a mutation, it doesn't know automatically what to invalidate, you need to do it manually: useMutation( {
onSuccess: () => {
queryClient.invalidateQueries( key );
}
} );Our |
|
A similar issue came up with #76767. The comments lack a proper custom-type API and are currently treated as a single entity. Adding a reaction (another comment type) invalidates the entire notes list. While we ended up using this to our advantage, I think it still highlights a lack of consumer-side control in more complex cases. What do you think we should provide alongside the P.S. Lack of a custom comment API is a whole different can of worms, so let's ignore that for the sake of the argument 😅 |
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the |
The advantage of If there is a new comment or a minor modification of an existing comment, we could write the new entity record into the existing Redux state ( The part that IMO doesn't work reliably is updating all queries correctly. When there are resolved results for a |
|
Thanks, @jsnajdr! That makes sense. I'll continue working on this and other |
What?
Note: Mostly wanted to run the idea with folks.
PR adds an
invalidateCacheoption tosaveEntityRecord, with a default oftrue. Existing behavior unchanged. This will allow consumers to opt out of cache invalidation if needed.Possible use case
Testing Instructions
No behavior change by default; existing
core-dataaction tests cover both paths.Use of AI Tools
Assisted by Claude.