-
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: Normalize _fields
value for use in stableKey
#27526
Conversation
Size Change: +9 B (0%) Total Size: 1.3 MB
ℹ️ View Unchanged
|
Just noticed the same in WordPress 5.6. @youknowriad Do you have any feedback on this PR? |
Thanks for catching this, is there a way to ensure that we use the same "functions" to encode the query in both places? |
@youknowriad we're much closer now, since both are using |
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.
Thanks for the fix, looks like there's still a failing unit test that
@@ -73,6 +73,8 @@ export function getQueryParts( query ) { | |||
// Example: Asking for titles in posts without title support. | |||
if ( key === '_fields' ) { | |||
parts.fields = getNormalizedCommaSeparable( value ); | |||
// Make sure to normalize value for `stableKey` | |||
value = parts.fields.join(); |
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.
Nit: should we be using another variable to avoid changing the semantic of the original variable.
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 stuck with changing value
so that we could leave the parts.stableKey
builder alone - I thought it would be simpler this way. Is there enough of a drawback here to reconsider that?
ec6e2f5
to
ffe270c
Compare
* Core Data: Normalize _fields value for use in stableKey * Fix existing tests * Fix selector used in tests
These are backports coming for the 5.6.1 release. Summary of the following issues: * [#27970](WordPress/gutenberg#27970) - Fix editor crash when registering a block pattern without `categories` Backport to WP Minor Release [Feature] Inserter [Feature] Patterns [Type] Bug * [#27733](WordPress/gutenberg#27733) - [Embed block]: Add html and reusable support back Backport to WP Minor Release [Block] Embed [Type] Regression * [#27727](WordPress/gutenberg#27727) - Add aria labels to box control component inputs/button Backport to WP Minor Release [Feature] UI Components [Package] Components [Type] Bug [a11y] Labelling * [#27627](WordPress/gutenberg#27627) - HTML Block: Fix editor styles Backport to WP Minor Release [Block] HTML [Type] Regression * [#27526](WordPress/gutenberg#27526) - Core Data: Normalize `_fields` value for use in `stableKey` Backport to WP Minor Release [Package] Core data [Type] Bug * [#26705](WordPress/gutenberg#26705) - Fix: Font size picker does not correctly handles big font sizes. Backport to WP Minor Release [Type] Bug * [#26432](WordPress/gutenberg#26432) - Edit Site: prevent inserter overscroll Backport to WP Minor Release First-time Contributor [Feature] Full Site Editing [Type] Bug Packages updated: @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] Fixes #52391. Props gziolo, whyisjake. git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50061 602fd350-edb4-49c9-b593-d223f7449a82
These are backports coming for the 5.6.1 release. Summary of the following issues: * [#27970](WordPress/gutenberg#27970) - Fix editor crash when registering a block pattern without `categories` Backport to WP Minor Release [Feature] Inserter [Feature] Patterns [Type] Bug * [#27733](WordPress/gutenberg#27733) - [Embed block]: Add html and reusable support back Backport to WP Minor Release [Block] Embed [Type] Regression * [#27727](WordPress/gutenberg#27727) - Add aria labels to box control component inputs/button Backport to WP Minor Release [Feature] UI Components [Package] Components [Type] Bug [a11y] Labelling * [#27627](WordPress/gutenberg#27627) - HTML Block: Fix editor styles Backport to WP Minor Release [Block] HTML [Type] Regression * [#27526](WordPress/gutenberg#27526) - Core Data: Normalize `_fields` value for use in `stableKey` Backport to WP Minor Release [Package] Core data [Type] Bug * [#26705](WordPress/gutenberg#26705) - Fix: Font size picker does not correctly handles big font sizes. Backport to WP Minor Release [Type] Bug * [#26432](WordPress/gutenberg#26432) - Edit Site: prevent inserter overscroll Backport to WP Minor Release First-time Contributor [Feature] Full Site Editing [Type] Bug Packages updated: @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] Fixes #52391. Props gziolo, whyisjake. Built from https://develop.svn.wordpress.org/branches/5.6@50061 git-svn-id: http://core.svn.wordpress.org/branches/5.6@49762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
These are backports coming for the 5.6.1 release. Summary of the following issues: * [#27970](WordPress/gutenberg#27970) - Fix editor crash when registering a block pattern without `categories` Backport to WP Minor Release [Feature] Inserter [Feature] Patterns [Type] Bug * [#27733](WordPress/gutenberg#27733) - [Embed block]: Add html and reusable support back Backport to WP Minor Release [Block] Embed [Type] Regression * [#27727](WordPress/gutenberg#27727) - Add aria labels to box control component inputs/button Backport to WP Minor Release [Feature] UI Components [Package] Components [Type] Bug [a11y] Labelling * [#27627](WordPress/gutenberg#27627) - HTML Block: Fix editor styles Backport to WP Minor Release [Block] HTML [Type] Regression * [#27526](WordPress/gutenberg#27526) - Core Data: Normalize `_fields` value for use in `stableKey` Backport to WP Minor Release [Package] Core data [Type] Bug * [#26705](WordPress/gutenberg#26705) - Fix: Font size picker does not correctly handles big font sizes. Backport to WP Minor Release [Type] Bug * [#26432](WordPress/gutenberg#26432) - Edit Site: prevent inserter overscroll Backport to WP Minor Release First-time Contributor [Feature] Full Site Editing [Type] Bug Packages updated: @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] Fixes #52391. Props gziolo, whyisjake. Built from https://develop.svn.wordpress.org/branches/5.6@50061 git-svn-id: https://core.svn.wordpress.org/branches/5.6@49762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This was shipped in 5.6.1, so removing the backport label: |
These are backports coming for the 5.6.1 release. Summary of the following issues: * [#27970](WordPress/gutenberg#27970) - Fix editor crash when registering a block pattern without `categories` Backport to WP Minor Release [Feature] Inserter [Feature] Patterns [Type] Bug * [#27733](WordPress/gutenberg#27733) - [Embed block]: Add html and reusable support back Backport to WP Minor Release [Block] Embed [Type] Regression * [#27727](WordPress/gutenberg#27727) - Add aria labels to box control component inputs/button Backport to WP Minor Release [Feature] UI Components [Package] Components [Type] Bug [a11y] Labelling * [#27627](WordPress/gutenberg#27627) - HTML Block: Fix editor styles Backport to WP Minor Release [Block] HTML [Type] Regression * [#27526](WordPress/gutenberg#27526) - Core Data: Normalize `_fields` value for use in `stableKey` Backport to WP Minor Release [Package] Core data [Type] Bug * [#26705](WordPress/gutenberg#26705) - Fix: Font size picker does not correctly handles big font sizes. Backport to WP Minor Release [Type] Bug * [#26432](WordPress/gutenberg#26432) - Edit Site: prevent inserter overscroll Backport to WP Minor Release First-time Contributor [Feature] Full Site Editing [Type] Bug Packages updated: @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] @wordpress/[email protected] Fixes #52391. Props gziolo, whyisjake. Built from https://develop.svn.wordpress.org/branches/5.6@50061 git-svn-id: http://core.svn.wordpress.org/branches/5.6@49762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Requests using
getEntityRecords
with_fields
specified are not returning any results. This seems to have been introduced with aa701ad (when _fields is added to stableKey), because the format used for encodingfields
here doesn't match the format used in the resolver.In my example below, if you look at the state, the key used is
_fields=id%2Cslug%2Ctitle
, whilestableKey
is_fields%5B0%5D=id&_fields%5B1%5D=slug&_fields%5B2%5D=title
. This mismatch means the results are never found in the state.I'm not sure if this is the best solution - there still could be a mismatch if the entity key is left out; the selector will add that into
fields
, while it won't be added ingetQueryParts
.To Test
Fetch records with getEntityRecords, like this:
useSelect
query, logging result the consolenull
, even after the API request completesTypes of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: