Blocks named null have been considered "empty," but "classic" blocks containing freeform HTML are also named null. This behavior is unexpected during content migrations involving non-block content, since the default behavior of match_blocks() on such content can return an empty set, leading to data loss.
With this change in this PR, blocks are considered empty if they are named null and contain only space in their inner HTML. This change has the potential to cause a different kind of confusion: Given a piece of HTML without any block delimiters, the default behavior of match_blocks() will now be to return a set of one block instead of an empty set.
I've chosen to proceed with the change despite this unintuitive result because the behavior of match_blocks() has tended to act as a reducer of the results returned by WP_Block_Parser, which also returns one block for the same HTML rather than eliminating the content from the parsed result.
Notes for reviewers
None.
Changelog entries
Added
Changed
"Classic" blocks, which have inner HTML but no block name, are no longer considered empty.
Summary
Blocks named
null
have been considered "empty," but "classic" blocks containing freeform HTML are also namednull
. This behavior is unexpected during content migrations involving non-block content, since the default behavior ofmatch_blocks()
on such content can return an empty set, leading to data loss.With this change in this PR, blocks are considered empty if they are named
null
and contain only space in their inner HTML. This change has the potential to cause a different kind of confusion: Given a piece of HTML without any block delimiters, the default behavior ofmatch_blocks()
will now be to return a set of one block instead of an empty set.I've chosen to proceed with the change despite this unintuitive result because the behavior of
match_blocks()
has tended to act as a reducer of the results returned byWP_Block_Parser
, which also returns one block for the same HTML rather than eliminating the content from the parsed result.Notes for reviewers
None.
Changelog entries
Added
Changed
Deprecated
Removed
Fixed
Security