[wp-trac] [WordPress Trac] #62290: Unable to seek to any bookmark in HTML Processor
WordPress Trac
noreply at wordpress.org
Thu Oct 24 15:26:48 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:
--------------------------+---------------------
Comment (by mi5t4n):
Replying to [comment:1 westonruter]:
> 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.
Running above code on the current trunk, does not throw any exceptions.
Trunk Version: 6.8-alpha-59274-src
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62290#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list