Skip to content
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: Add checks to actions and selectors to avoid throwing errors when the relevant config is not loaded. #18559

Merged
merged 4 commits into from
Nov 20, 2019

Conversation

epiqueras
Copy link
Contributor

Description

This PR adds some checks and guards to avoid throwing errors when editEntityRecord or isEditedPostDirty are called without the relevant entity config being loaded.

How has this been tested?

It was verified that running:

wp.data.dispatch( 'core' ).editEntityRecord( 'someKind', 'someName', 'someId', {} )

and

wp.data.select( 'core' ).getEntityRecordNonTransientEdits( 'someKind', 'someName', 'someId' )

for inexistent entity configs is handled gracefully.

Types of Changes

Bug Fix: editEntityRecord and isEditedPostDirty no longer throw an error when called before core-data is initialized.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@epiqueras epiqueras added [Type] Bug An existing feature does not function as intended [Package] Core data /packages/core-data labels Nov 16, 2019
@epiqueras epiqueras added this to the Future milestone Nov 16, 2019
@epiqueras epiqueras requested a review from nerrad as a code owner November 16, 2019 16:17
@epiqueras epiqueras self-assigned this Nov 16, 2019
Copy link
Contributor

@nerrad nerrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can add some unit tests, to ensure these selectors/actions don't break when called early.

@epiqueras
Copy link
Contributor Author

Updated and Tested! 🚀

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

@epiqueras epiqueras merged commit d3e7c6b into master Nov 20, 2019
@epiqueras epiqueras deleted the add/core-data-safety-guards branch November 20, 2019 17:10
@youknowriad youknowriad modified the milestones: Future, Gutenberg 7.0 Nov 25, 2019
youknowriad pushed a commit that referenced this pull request Dec 5, 2019
…rs when the relevant config is not loaded. (#18559)

* Core Data: Add checks to selectors to avoid throwing errors when the relevant config is not loaded.

* Core Data: Throw when `editEntityRecord` targets an entity without a config.

* Core Data: Fix default value typo in `getEntityRecordNonTransientEdits`.

* Core Data: Test the behavior of `editEntityRecord` and `getEntityRecordNonTransientEdits` on entities without configs.
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Fixes #48884.

git-svn-id: https://develop.svn.wordpress.org/trunk@46860 602fd350-edb4-49c9-b593-d223f7449a82
nylen pushed a commit to nylen/wordpress-develop-svn that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Fixes #48884.

git-svn-id: https://develop.svn.wordpress.org/trunk@46860 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Fixes #48884.
Built from https://develop.svn.wordpress.org/trunk@46860


git-svn-id: http://core.svn.wordpress.org/trunk@46660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Fixes #48884.
Built from https://develop.svn.wordpress.org/trunk@46860


git-svn-id: https://core.svn.wordpress.org/trunk@46660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Merges [46860] to the 5.3 branch.
Fixes #48884.

git-svn-id: https://develop.svn.wordpress.org/branches/5.3@46861 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Merges [46860] to the 5.3 branch.
Fixes #48884.
Built from https://develop.svn.wordpress.org/branches/5.3@46861


git-svn-id: http://core.svn.wordpress.org/branches/5.3@46661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Dec 9, 2019
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Merges [46860] to the 5.3 branch.
Fixes #48884.
Built from https://develop.svn.wordpress.org/branches/5.3@46861


git-svn-id: https://core.svn.wordpress.org/branches/5.3@46661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
sikc8000 pushed a commit to sikc8000/u0_a165-localhost that referenced this pull request Feb 20, 2020
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Fixes #48884.
Built from https://develop.svn.wordpress.org/trunk@46860
sikc8000 pushed a commit to sikc8000/u0_a165-localhost that referenced this pull request Feb 20, 2020
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Merges [46860] to the 5.3 branch.
Fixes #48884.
Built from https://develop.svn.wordpress.org/branches/5.3@46861
miya0001 pushed a commit to cjk4wp/wordpress that referenced this pull request Feb 20, 2020
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Fixes #48884.

git-svn-id: http://develop.svn.wordpress.org/trunk@46860 602fd350-edb4-49c9-b593-d223f7449a82
VenusPR added a commit to VenusPR/Wordpress_Richard that referenced this pull request Mar 9, 2023
The list of included fixes:

- Edge scrolling issues WordPress/gutenberg#17707
- Intermittent JavaScript issues WordPress/gutenberg#18559
- Remove embed CollegeHumor WordPress/gutenberg#18591 

Updated packages:

- @wordpress/block-directory@1.0.6
- @wordpress/block-editor@3.2.5
- @wordpress/block-library@2.9.6
- @wordpress/core-data@2.7.5
- @wordpress/edit-post@3.8.6
- @wordpress/editor@9.7.6
- @wordpress/format-library@1.9.5

Props youknowriad, ellatrix, epiqueras, audrasjb, gziolo, mcsf, kyliesabra.
Merges [46860] to the 5.3 branch.
Fixes #48884.
Built from https://develop.svn.wordpress.org/branches/5.3@46861


git-svn-id: http://core.svn.wordpress.org/branches/5.3@46661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants