Make WordPress Core

Ticket #54558: 54558.1.diff

File 54558.1.diff, 812 bytes (added by costdev, 3 years ago)

Patch updated to remove new error by covering paths of array type.

  • src/wp-includes/block-editor.php

    diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php
    index aaa249cb7b..13445af745 100644
    a b function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont 
    468468         */
    469469        $backup_global_post = ! empty( $post ) ? clone $post : $post;
    470470
     471        foreach ( $preload_paths as &$path ) {
     472                if ( is_string( $path ) && ! str_starts_with( $path, '/' ) ) {
     473                        $path = '/' . $path;
     474                }
     475
     476                if ( is_array( $path ) ) {
     477                        foreach( $path as &$part ) {
     478                                if ( is_string( $part )
     479                                        && $path === strtolower( $part )
     480                                        && ! str_starts_with( $part ) ) {
     481                                        $part = '/' . $part;
     482                                }
     483                        }
     484                }
     485        }
     486
    471487        $preload_data = array_reduce(
    472488                $preload_paths,
    473489                'rest_preload_api_request',