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

epiqueras commented Nov 16, 2019

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. .
…relevant config is not loaded.
@epiqueras epiqueras added this to the Future milestone Nov 16, 2019
@epiqueras epiqueras requested a review from youknowriad Nov 16, 2019
@epiqueras epiqueras requested a review from nerrad as a code owner Nov 16, 2019
@epiqueras epiqueras self-assigned this Nov 16, 2019
@nerrad
nerrad approved these changes Nov 17, 2019
Copy link
Contributor

nerrad left a comment

Looks good to me.

Copy link
Contributor

youknowriad left a comment

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

@epiqueras

This comment has been minimized.

Copy link
Contributor Author

epiqueras commented Nov 19, 2019

Updated and Tested! 🚀

Copy link
Contributor

youknowriad left a comment

Cool

@epiqueras epiqueras merged commit d3e7c6b into master Nov 20, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@epiqueras epiqueras deleted the add/core-data-safety-guards branch Nov 20, 2019
@youknowriad youknowriad modified the milestones: Future, Gutenberg 7.0 Nov 25, 2019
youknowriad added 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.