Make WordPress Core

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: tusharbharti's profile tusharbharti 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

  1. Use allowed_block_types_all to only allow core/columns.
  2. Register a pattern containing both core/columns and core/column.
  3. Visit the editor and open the pattern inserter.
  4. 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

#2 @tusharbharti
8 hours ago

  • Keywords 2nd-opinion added
Note: See TracTickets for help on using tickets.