[wp-trac] [WordPress Trac] #62290: Unable to seek to any bookmark in HTML Processor
WordPress Trac
noreply at wordpress.org
Thu Oct 24 00:51:03 UTC 2024
#62290: Unable to seek to any bookmark in HTML Processor
--------------------------+---------------------
Reporter: westonruter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.7.1
Component: HTML API | Version: 6.6
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+---------------------
Changes (by westonruter):
* version: trunk => 6.6
* milestone: Awaiting Review => 6.7.1
Comment:
The issue also occurs with fragments:
{{{#!php
<?php
$bookmark_name = 'the-bookmark';
$html = <<<HTML
<div id="$bookmark_name"></div>
HTML;
$processor = WP_HTML_Processor::create_fragment( $html );
while ( $processor->next_tag() ) {
if ( 'DIV' === $processor->get_tag() ) {
if ( ! $processor->set_bookmark( $bookmark_name ) ) {
throw new Exception( "Failed to set bookmark" );
}
}
}
if ( ! $processor->has_bookmark( $bookmark_name ) ) {
throw new Exception( "Unexpectedly has_bookmark returned false."
);
}
if ( ! $processor->seek( $bookmark_name ) ) {
throw new Exception( "Failed to seek to bookmark." );
}
}}}
With this code, I get no exception if I run it against the 6.5 branch, but
I get exceptions when I run it against the 6.6 and 6.7 branches.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62290#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list