Opened 3 weeks ago
Closed 2 weeks ago
#64537 closed defect (bug) (fixed)
Block Processor: Extracting full block missing nested content.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9.1 | Priority: | normal |
| Severity: | normal | Version: | 6.9 |
| Component: | Editor | Keywords: | has-patch has-unit-tests dev-reviewed fixed-major |
| Focuses: | Cc: |
Description (last modified by )
The behavior of WP_Block_Processor::extract_full_block_and_advance() should produce an identical output to what parse_blocks() would return on the same substring of input.
It has difficulties in certain nested contexts. In the following case, the trailing </ul> is missing. In several test cases the trailing HTML span is missing, at least from innerContent.
<!-- wp:columns --><ul><!-- wp:column --><li>Hi</li><!-- /wp:column --></ul><!-- /wp:columns -->
There is likely a problem in the recursive part of the algorithm, or in recognizing HTML spans, or in performing proper stack accounting, or all three.
Reported by @jonsurrell
Change History (15)
This ticket was mentioned in PR #10769 on WordPress/wordpress-develop by @dmsnell.
3 weeks ago
#1
- Keywords has-patch has-unit-tests added
@dmsnell commented on PR #10769:
3 weeks ago
#3
Only one of the tests seem to have any block attributes. Is this intentional, if not would it make sense to make sure that more of those don't affect the block processor vs. parse blocks?
I can add more, @aaronjorbin, but I think I only really felt like one was essential for this specific bug, mostly to ensure that it works _at all_ vs. having a big gap. The attribute testing is handled by other unit tests which parse block delimiters, but I suppose here it could be useful to ensure that attributes are properly assigned in nested contexts (vs. being assigned to a block’s containing outer block)
@dmsnell commented on PR #10769:
3 weeks ago
#4
@aaronjorbin in the latest push I’ve added tests that I think should be sufficient to ensure that block attribute parsing doesn’t run amok. That is, four levels deep I’m testing _no attributes_, _empty attributes_, _attributes_, and _attributes with the same key but different value as its parent block_.
@dmsnell commented on PR #10769:
3 weeks ago
#5
As a side note to this change, I intentionally don’t want to verify the error-handling behavior of malformed posts. That’s a more complicated subject, because the default parser is technically not spec-compliant, and if we assert those behaviors on the current parse_blocks() we will lock ourselves in to that ad-hoc error-resolution.
Coincidentally, I am proposing a change in error-handling in wordpress/Gutenberg#74427 in the default parser to resolve a longstanding memory-explosion time bomb.
#7
@
3 weeks ago
- Keywords dev-feedback added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for review for 6.9.1 backport.
This ticket was mentioned in Slack in #core by jorbin. View the logs.
3 weeks ago
This ticket was mentioned in PR #10772 on WordPress/wordpress-develop by @jorbin.
3 weeks ago
#10
#11
@
3 weeks ago
Setup a PR to ensure all tests pass with this on the 6.9 branch and there are no complications with a backport.
This ticket was mentioned in PR #10774 on WordPress/wordpress-develop by @jonsurrell.
3 weeks ago
#13
# This is a backport test PR for [61509]
The behavior of WP_Block_Processor::extract_full_block_and_advance() should produce an identical output to what parse_blocks() would return on the same substring of input.
Unfortunately, when HTML spans followed inner blocks, they were being omitted in the output parse tree. This was due to an omission in the original code which would look for those blocks before advancing again after calling
extract_full_block_and_advance()recursively.
This patch adds the missing check and resolves the discrepancy.
Developed in: https://github.com/WordPress/wordpress-develop/pull/10769.
Discussed in: https://core.trac.wordpress.org/ticket/64538.
Trac ticket: https://core.trac.wordpress.org/ticket/64537
@jonsurrell commented on PR #10774:
3 weeks ago
#14
This diff should match d3068ae now.
Trac ticket: Core-64537
The behavior of WP_Block_Processor::extract_full_block_and_advance() should produce an identical output to what parse_blocks() would return on the same substring of input.
It has difficulties in certain nested contexts. In the following case, the trailing </ul> is missing. In several test cases the trailing HTML span is missing, at least from innerContent.
There is likely a problem in the recursive part of the algorithm, or in recognizing HTML spans, or in performing proper stack accounting, or all three.