Commit 7d24121b80 for wordpress.org

commit 7d24121b8016e788cfca43d00fe1a85da0fdf1e3
Author: luisherranz <luisherranz@git.wordpress.org>
Date:   Tue Nov 10 05:23:55 2026 +0000

    Interactivity API: Choose the `data-wp-html` placeholder marker in linear time.

    Replace the repeated input-search loop with a UUID-based marker, generated
    when the first `data-wp-html` host renders and reused by subsequent hosts
    in the same processing call.

    This removes input-dependent searching, keeps placeholder length fixed,
    and avoids generating a UUID when no host renders.

    Props jonsurrell.
    Fixes #66498.
    Built from https://develop.svn.wordpress.org/trunk@65371


    git-svn-id: http://core.svn.wordpress.org/trunk@64510 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/interactivity-api/class-wp-interactivity-api.php b/wp-includes/interactivity-api/class-wp-interactivity-api.php
index 2190e125d0..506abd0153 100644
--- a/wp-includes/interactivity-api/class-wp-interactivity-api.php
+++ b/wp-includes/interactivity-api/class-wp-interactivity-api.php
@@ -183,8 +183,9 @@ final class WP_Interactivity_API {

 	/**
 	 * Marker that makes the placeholders of the current `process_directives()`
-	 * call recognizable. It occurs nowhere in the HTML that call received, and
-	 * it differs from the marker of any call that the current one runs inside.
+	 * call recognizable, or an empty string until the first `data-wp-html` host
+	 * of the call renders and draws it. It holds a random UUID, so no text
+	 * written before the call can realistically hold it.
 	 *
 	 * @since 7.2.0
 	 * @var string
@@ -536,17 +537,11 @@ final class WP_Interactivity_API {
 		/*
 		 * The trusted HTML of `data-wp-html` hosts never takes part in the
 		 * processing: each host receives a placeholder comment, and the comments
-		 * are replaced by their HTML once the result is known. The marker that
-		 * identifies them is chosen so that it occurs nowhere in the input, which
-		 * makes it impossible for the input to contain a placeholder. It is also
-		 * longer than the marker of any call this one runs inside, so their
-		 * placeholders never coincide.
+		 * are replaced by their HTML once the result is known. The call starts
+		 * without the marker that identifies them: the first host that renders
+		 * draws it, so a call without such a host does no marker work.
 		 */
-		$marker = '' === $this->html_placeholder_marker ? 'wp-interactivity-dangerous-html' : $this->html_placeholder_marker . '_';
-		while ( str_contains( $html, $marker ) ) {
-			$marker .= '_';
-		}
-		$this->html_placeholder_marker = $marker;
+		$this->html_placeholder_marker = '';
 		$this->html_placeholders       = array();

 		try {
@@ -1698,8 +1693,13 @@ final class WP_Interactivity_API {
 		/*
 		 * The HTML is held back and a placeholder comment takes its place, so no
 		 * later step of the call scans it. A comment is a single token for the
-		 * processors, and the marker in it occurs nowhere in the input.
+		 * processors. Its marker holds a random UUID, drawn once per call by the
+		 * first host that renders, so no text written before the call can
+		 * realistically contain a placeholder.
 		 */
+		if ( '' === $this->html_placeholder_marker ) {
+			$this->html_placeholder_marker = 'wp-interactivity-dangerous-html-' . wp_generate_uuid4();
+		}
 		$placeholder = '<!--' . $this->html_placeholder_marker . ':' . count( $this->html_placeholders ) . '-->';
 		if ( $p->skip_to_balanced_tag_closer( $placeholder ) ) {
 			$this->html_placeholders[ $placeholder ] = $html;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index dba5cd40e6..42da5ef265 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-beta4-65370';
+$wp_version = '7.2-beta4-65371';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.