From cf2a88a3976d86a4c7e90fc5f17090f1bfc5f86e Mon Sep 17 00:00:00 2001 From: dmsnell Date: Sat, 8 Jun 2024 11:12:11 +0000 Subject: [PATCH] HTML API: Fix three small type-related bugs. This applies three fixes that appeared as part of adding type annotations to the HTML API. Developed in https://github.com/WordPress/wordpress-develop/pull/6754 Discussed in https://core.trac.wordpress.org/ticket/61399 Props jonsurrell. See #61399. Follow-up to [55203], [56274]. Built from https://develop.svn.wordpress.org/trunk@58364 git-svn-id: http://core.svn.wordpress.org/trunk@57813 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/html-api/class-wp-html-processor.php | 2 +- wp-includes/html-api/class-wp-html-tag-processor.php | 6 ++++-- wp-includes/version.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index eeafca44f7..0511035607 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -543,7 +543,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { // Avoid sending close events for elements which don't expect a closing. if ( WP_HTML_Stack_Event::POP === $this->current_element->operation && - ! static::expects_closer( $this->current_element->token->node_name ) + ! static::expects_closer( $this->current_element->token ) ) { return $this->next_token(); } diff --git a/wp-includes/html-api/class-wp-html-tag-processor.php b/wp-includes/html-api/class-wp-html-tag-processor.php index 99f37dcf08..dafa17daea 100644 --- a/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/wp-includes/html-api/class-wp-html-tag-processor.php @@ -2265,7 +2265,7 @@ class WP_HTML_Tag_Processor { * @param int $shift_this_point Accumulate and return shift for this position. * @return int How many bytes the given pointer moved in response to the updates. */ - private function apply_attributes_updates( $shift_this_point = 0 ) { + private function apply_attributes_updates( $shift_this_point ) { if ( ! count( $this->lexical_updates ) ) { return 0; } @@ -2787,6 +2787,8 @@ class WP_HTML_Tag_Processor { case self::STATE_FUNKY_COMMENT: return '#funky-comment'; } + + return null; } /** @@ -3195,7 +3197,7 @@ class WP_HTML_Tag_Processor { * Keep track of the position right before the current tag. This will * be necessary for reparsing the current tag after updating the HTML. */ - $before_current_tag = $this->token_starts_at; + $before_current_tag = $this->token_starts_at ?? 0; /* * 1. Apply the enqueued edits and update all the pointers to reflect those changes. diff --git a/wp-includes/version.php b/wp-includes/version.php index b9ad2cc932..969baf30ba 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-beta1-58363'; +$wp_version = '6.6-beta1-58364'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.