Opened 11 hours ago
Last modified 8 hours ago
#63765 new defect (bug)
register_block_pattern() returns true even when disallowed blocks are used, causing silent failure in the editor.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.8.2 |
Component: | Editor | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
Description
This issue was initially reported in the Gutenberg GitHub repo (https://github.com/WordPress/gutenberg/issues/59413).
When registering a block pattern using register_block_pattern()
, if the pattern includes blocks that are not explicitly allowed via the allowed_block_types_all
filter, the function still returns true
. However, the pattern does not appear in the editor's pattern inserter, and no warning or error is shown.
This behavior is inconsistent. For example, the core/column
block is usable inside the editor if core/columns
is whitelisted, even without explicitly allowing core/column
. But when used in a pattern, core/column
must be separately whitelisted, or the pattern is silently skipped.
Steps to Reproduce
- Use
allowed_block_types_all
to only allowcore/columns
. - Register a pattern containing both
core/columns
andcore/column
. - Visit the editor and open the pattern inserter.
- The pattern will not appear, though
register_block_pattern()
returned true.
Expected Behavior
- Either register_block_pattern() should return false or log a warning when the pattern includes disallowed blocks.
- Or nested blocks (like core/column) should be implicitly allowed when their parent (like core/columns) is whitelisted, for consistency.
Actual Behavior
- register_block_pattern() returns true.
- The pattern does not appear in the inserter.
- No error or warning is provided.
Proposal
Add block-type validation to register_block_pattern()
that checks pattern content against the current block whitelist (allowed_block_types_all
). If disallowed blocks are found, return false
or trigger a developer warning.
Change History (3)
This ticket was mentioned in PR #9345 on WordPress/wordpress-develop by @tusharbharti.
8 hours ago
#1
- Keywords has-patch added
#3
@
8 hours ago
For Bug Reproduction reports, I believe
- [Bug Reproduction Report]https://github.com/WordPress/gutenberg/issues/59413#issuecomment-2939341612
and
- [Bug Reproduction Report]https://github.com/WordPress/gutenberg/issues/59413#issuecomment-3127669702
should suffice.
Trac ticket: https://core.trac.wordpress.org/ticket/63765