-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core data: Fix wrong store results when page receives less items that what is stored #55832
Conversation
…at what is stored
Size Change: +1.31 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in 4d77693. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6772499491
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not tottaly, sure about the impact of this change. Maybe @youknowriad could have a look. But the change seems to make sense and fixes the issue with removing drafs in my tests. End to end tests are passing and the application seems fine so it seems there is no negative impact,
@@ -55,7 +55,7 @@ function getQueriedItemsUncached( state, query ) { | |||
|
|||
// Having a target item ID doesn't guarantee that this object has been queried. | |||
if ( ! state.items[ context ]?.hasOwnProperty( itemId ) ) { | |||
return null; | |||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this change, I wonder if this was there to ensure that we only return values if all the ids of the given query have been fetched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my question is: is this change required for this PR. If so, can you explain why/how?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I tried to make a similar change in #34034 but eventually reverted it. Unfortunately, I don't have any additional input besides what was shared in that PR.
The lack of higher-level/integration tests here makes it easier for regressions to slip in even when changes are minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my question is: is this change required for this PR. If so, can you explain why/how?
In this PR if we have fewer items received, we don't add the previous ones(that was the bug), but instead fill it with undefined
. Without this change the query will not return anything. Something I was thinking about was, whether to explicitly check for undefined
and continue
only in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for filling with undefined
instead of just removing them from the itemIds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we need the array(itemIds) to be sparse-like with undefined
entries where holes exist, for pagination to work properly. If we don't do that and just remove the item there, my understanding is that can break other queries with different page
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm still not sure I understand the real reason, what things would break but regardless it seems safer to only "continue" here if the itemId is undefined like you suggested to minimize the impact of this PR.
Thanks for the update, I think we can land this but let's keep an eye on weird issues related to queries... |
Follow up of: #55781
The linked PR surfaced a bug we have in core-data cache handling in some cases. The use case is when have cached a page's results and the new items are less than what was stored before. Currently in trunk we would add at the end of the array the remaining results from previous data.
Testing Instructions
Trash
view(assuming you have sometrash
pages there) and click therestore
iconstatus:trash
pages