Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/wp-includes/class-wp-block-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
* block, and re-serialize it into the original document. It’s possible to do so
* while skipping over the parse of the rest of the document.
*
* {@see self::extract_block()} will scan forward from the current block opener
* {@see self::extract_full_block_and_advance()} will scan forward from the current block opener
* and build the parsed block structure until the current block is closed. It will
* include all inner HTML and inner blocks, and parse all of the inner blocks. It
* can be used to extract a block at any depth in the document, helpful for operating
Expand All @@ -207,7 +207,7 @@
* }
*
* $gallery_at = $processor->get_span()->start;
* $gallery_block = $processor->extract_block();
* $gallery_block = $processor->extract_full_block_and_advance();
* $after_gallery = $processor->get_span()->start;
* return (
* substr( $post_content, 0, $gallery_at ) .
Expand Down Expand Up @@ -1223,7 +1223,7 @@ public function get_depth(): int {
* }
*
* $gallery_at = $processor->get_span()->start;
* $gallery = $processor->extract_block();
* $gallery = $processor->extract_full_block_and_advance();
* $ends_before = $processor->get_span();
* $ends_before = $ends_before->start ?? strlen( $post_content );
*
Expand Down Expand Up @@ -1254,7 +1254,7 @@ public function get_depth(): int {
* }
* }
*/
public function extract_block(): ?array {
public function extract_full_block_and_advance(): ?array {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add extract_block as an alias method which we can warn with deprecation notice and @deprecated that it will be removed in 7.0? This would eliminate any risk for the rename. Given this change is made during RC this would seem safest.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems fine, but at the same time I figure it’s probably no safer to remove it in 7.0 than it would be now.

I’m worried that if we push it out then it will have to stay forever.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer because there would be time to update, longer than 1½ weeks.

I don't feel strongly, however.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class has not been in a release. It's new in 6.9. The only sites that could be impacted are those that are running trunk and relying on this brand new API. Running trunk is inherently dangerous and not recommended.

If this method needs to be renamed, it seems best to me to do a clean rename right now and avoid the need for deprecations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to try and rename it before the release. It is rather new in trunk even as @sirreal mentioned. If there is any transition pain, and I hope there isn’t, I hope it will save a lot of future hassle.

if ( $this->is_html() ) {
$chunk = $this->get_html_content();

Expand Down Expand Up @@ -1291,7 +1291,7 @@ public function extract_block(): ?array {
* @todo Use iteration instead of recursion, or at least refactor to tail-call form.
*/
if ( $this->opens_block() ) {
$inner_block = $this->extract_block();
$inner_block = $this->extract_full_block_and_advance();
$block['innerBlocks'][] = $inner_block;
$block['innerContent'][] = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function test_builds_block( $block_content ) {

$extracted = array();
while ( $processor->next_block( '*' ) ) {
$extracted[] = $processor->extract_block();
$extracted[] = $processor->extract_full_block_and_advance();
}

$this->assertSame(
Expand Down
Loading