close
Skip to content

Fix: contributor/author synced pattern visibility#70440

Open
karthikeya-io wants to merge 1 commit intoWordPress:trunkfrom
karthikeya-io:fix/contributor-synced-pattern-visibility
Open

Fix: contributor/author synced pattern visibility#70440
karthikeya-io wants to merge 1 commit intoWordPress:trunkfrom
karthikeya-io:fix/contributor-synced-pattern-visibility

Conversation

@karthikeya-io
Copy link
Copy Markdown
Contributor

@karthikeya-io karthikeya-io commented Jun 16, 2025

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, useEntityRecord and useEntityBlockEditor are used to retrieve the synced pattern in the ReusableBlockEdit component. These hooks call the endpoint /index.php?rest_route=/wp/v2/blocks/id&context=edit&_locale=user which 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 useEntityRecords to fetch the synced pattern, which does not produce a 403 error.

Testing Instructions

  1. Log in as an admin, create a synced pattern, and add it to a post.
  2. Log in as a contributor or author, and open the post containing the synced pattern.
  3. Confirm that the message “Block has been deleted or is unavailable.” is not displayed for the pattern.

Testing Instructions for Keyboard

Same

Screenshots or screencast

Before After
image image

@karthikeya-io karthikeya-io marked this pull request as ready for review June 27, 2025 12:02
@github-actions
Copy link
Copy Markdown

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.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

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.

@github-actions
Copy link
Copy Markdown

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 props-bot label.

Unlinked Accounts

The 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.

Unlinked contributors: denisprado.

Co-authored-by: karthikeya-io <karthikeya01@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contributors Cannot View Synced Patterns (Patterns), Hindering Content Editing

1 participant