Fix: contributor/author synced pattern visibility#70440
Fix: contributor/author synced pattern visibility#70440karthikeya-io wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @denisprado. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What?
Closes #70222
Fixes the "Block has been deleted or is unavailable." message shown for synced patterns when viewed by users without edit permissions for the synced pattern (e.g., Contributors or Authors).
Why?
Currently,
useEntityRecordanduseEntityBlockEditorare used to retrieve the synced pattern in theReusableBlockEditcomponent. These hooks call the endpoint/index.php?rest_route=/wp/v2/blocks/id&context=edit&_locale=userwhich returns a 403 error for contributors and authors who lack edit access to the pattern. That leads to the “Block has been deleted or is unavailable.” message until another endpoint updates the store with the blocks.How?
To prevent this, if the user lacks edit capabilities we fall back to using
useEntityRecordsto fetch the synced pattern, which does not produce a 403 error.Testing Instructions
Testing Instructions for Keyboard
Same
Screenshots or screencast