close

Make WordPress Core

Changeset 61914


Ignore:
Timestamp:
03/10/2026 09:18:06 PM (3 days ago)
Author:
johnbillion
Message:

Customize: Introduce a fix for themes that pass a stringable object through the template_include filter despite it being documented as only accepting a string.

This has historically worked until [61892] increased the strictness of the template file validation which dismissed any value of a type other than a string, which a stringable object is not.

Merges [61913] into the 6.9 branch.

Props dmsnell, westonruter.

Location:
branches/6.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.9

  • branches/6.9/src/wp-includes/class-wp-block-patterns-registry.php

    r61892 r61914  
    175175        }
    176176
    177         $pattern_path = realpath( $patterns[ $pattern_name ]['filePath'] ?? '' );
     177        $file_path    = $patterns[ $pattern_name ]['filePath'] ?? '';
     178        $is_stringy   = is_string( $file_path ) || ( is_object( $file_path ) && method_exists( $file_path, '__toString' ) );
     179        $pattern_path = $is_stringy ? realpath( (string) $file_path ) : null;
    178180        if (
    179181            ! isset( $patterns[ $pattern_name ]['content'] ) &&
  • branches/6.9/src/wp-includes/template-loader.php

    r61892 r61914  
    112112     * @param string $template The path of the template to include.
    113113     */
    114     $template = apply_filters( 'template_include', $template );
    115     $template = is_string( $template ) ? realpath( $template ) : null;
     114    $template   = apply_filters( 'template_include', $template );
     115    $is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
     116    $template   = $is_stringy ? realpath( (string) $template ) : null;
    116117    if (
    117118        is_string( $template ) &&
Note: See TracChangeset for help on using the changeset viewer.