Repository navigation
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
|
jorgefilipecosta
left a comment
There was a problem hiding this comment.
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,
| // 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.
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.
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.
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.
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.
What is the reason for filling with undefined instead of just removing them from the itemIds?
There was a problem hiding this comment.
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.
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
Trashview(assuming you have sometrashpages there) and click therestoreiconstatus:trashpages