Commit e36ab473f3 for wordpress.org

commit e36ab473f3c9357974be98db93c6af78d82b13e0
Author: westonruter <westonruter@git.wordpress.org>
Date:   Mon Sep 21 18:35:49 2026 +0000

    REST API: Honor subclass overrides of `canonicalize_header_name()`.

    The five header accessors in `WP_REST_Request` now reach the static `canonicalize_header_name()` as `static::` rather than through `$this->`, so it is visible at the call site that the method is static and that `$this` plays no part inside it. This much is a readability change only: PHP already resolves a static method called with `->` against the object's actual class, so dispatch is unchanged. Only `self::` binds early, and it was never used here.

    In `WP_REST_Server::get_target_hints_for_link()` the same method was called on a hard-coded `WP_REST_Request`, which genuinely did defeat late static binding. Because `WP_REST_Request::from_url()` returns the result of the `rest_request_from_url` filter, a plugin can substitute a subclass there, and an override of `canonicalize_header_name()` on that subclass was silently ignored. The call now resolves against the request object actually in hand.

    The unit test covering the method calls it on the class rather than through a request instance, which states its static nature directly and drops a dependency the test never needed.

    Developed in https://github.com/WordPress/wordpress-develop/pull/13570.
    Follow-up to r34928, r40577, r59032.

    Props arshidkv12, tobiasbg, westonruter.
    Fixes #66122.

    Built from https://develop.svn.wordpress.org/trunk@63780


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

diff --git a/wp-includes/rest-api/class-wp-rest-request.php b/wp-includes/rest-api/class-wp-rest-request.php
index a6169ada2c..6e2619afeb 100644
--- a/wp-includes/rest-api/class-wp-rest-request.php
+++ b/wp-includes/rest-api/class-wp-rest-request.php
@@ -211,7 +211,7 @@ class WP_REST_Request implements ArrayAccess {
 	 * @return string|null String value if set, null otherwise.
 	 */
 	public function get_header( $key ) {
-		$key = $this->canonicalize_header_name( $key );
+		$key = static::canonicalize_header_name( $key );

 		if ( ! isset( $this->headers[ $key ] ) ) {
 			return null;
@@ -229,7 +229,7 @@ class WP_REST_Request implements ArrayAccess {
 	 * @return array|null List of string values if set, null otherwise.
 	 */
 	public function get_header_as_array( $key ) {
-		$key = $this->canonicalize_header_name( $key );
+		$key = static::canonicalize_header_name( $key );

 		if ( ! isset( $this->headers[ $key ] ) ) {
 			return null;
@@ -247,7 +247,7 @@ class WP_REST_Request implements ArrayAccess {
 	 * @param string $value Header value, or list of values.
 	 */
 	public function set_header( $key, $value ) {
-		$key   = $this->canonicalize_header_name( $key );
+		$key   = static::canonicalize_header_name( $key );
 		$value = (array) $value;

 		$this->headers[ $key ] = $value;
@@ -262,7 +262,7 @@ class WP_REST_Request implements ArrayAccess {
 	 * @param string $value Header value, or list of values.
 	 */
 	public function add_header( $key, $value ) {
-		$key   = $this->canonicalize_header_name( $key );
+		$key   = static::canonicalize_header_name( $key );
 		$value = (array) $value;

 		if ( ! isset( $this->headers[ $key ] ) ) {
@@ -280,7 +280,7 @@ class WP_REST_Request implements ArrayAccess {
 	 * @param string $key Header name.
 	 */
 	public function remove_header( $key ) {
-		$key = $this->canonicalize_header_name( $key );
+		$key = static::canonicalize_header_name( $key );
 		unset( $this->headers[ $key ] );
 	}

diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php
index 426f20d41d..140e14122d 100644
--- a/wp-includes/rest-api/class-wp-rest-server.php
+++ b/wp-includes/rest-api/class-wp-rest-server.php
@@ -738,7 +738,7 @@ class WP_REST_Server {
 		$headers = rest_send_allow_header( $response, $server, $request )->get_headers();

 		foreach ( $headers as $name => $value ) {
-			$name = WP_REST_Request::canonicalize_header_name( $name );
+			$name = $request::canonicalize_header_name( $name );

 			$target_hints[ $name ] = array_map( 'trim', explode( ',', $value ) );
 		}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index cfb3050222..c2d47cd065 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-63779';
+$wp_version = '7.2-alpha-63780';

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