Coding Standards: Break the `$path` reference after a `foreach` loop in `block_editor_rest_api_preload()`.
When using a `foreach` loop with a value assigned by reference, the variable continues to point to the last array element even after the loop, so it is recommended to destroy it by `unset()` to avoid unexpected behavior later on. See [https://www.php.net/manual/en/control-structures.foreach.php PHP Manual: foreach]. Follow-up to [52312], [52313]. Props TobiasBg. See #54558. Built from https://develop.svn.wordpress.org/trunk@52322 git-svn-id: http://core.svn.wordpress.org/trunk@51914 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6b84ae03ad
commit
6e09421269
|
@ -83,6 +83,7 @@ function get_block_categories( $post_or_block_editor_context ) {
|
||||||
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
||||||
*/
|
*/
|
||||||
$block_categories = apply_filters( 'block_categories_all', $block_categories, $block_editor_context );
|
$block_categories = apply_filters( 'block_categories_all', $block_categories, $block_editor_context );
|
||||||
|
|
||||||
if ( ! empty( $block_editor_context->post ) ) {
|
if ( ! empty( $block_editor_context->post ) ) {
|
||||||
$post = $block_editor_context->post;
|
$post = $block_editor_context->post;
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ function get_allowed_block_types( $block_editor_context ) {
|
||||||
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
||||||
*/
|
*/
|
||||||
$allowed_block_types = apply_filters( 'allowed_block_types_all', $allowed_block_types, $block_editor_context );
|
$allowed_block_types = apply_filters( 'allowed_block_types_all', $allowed_block_types, $block_editor_context );
|
||||||
|
|
||||||
if ( ! empty( $block_editor_context->post ) ) {
|
if ( ! empty( $block_editor_context->post ) ) {
|
||||||
$post = $block_editor_context->post;
|
$post = $block_editor_context->post;
|
||||||
|
|
||||||
|
@ -397,6 +399,7 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
||||||
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
||||||
*/
|
*/
|
||||||
$editor_settings = apply_filters( 'block_editor_settings_all', $editor_settings, $block_editor_context );
|
$editor_settings = apply_filters( 'block_editor_settings_all', $editor_settings, $block_editor_context );
|
||||||
|
|
||||||
if ( ! empty( $block_editor_context->post ) ) {
|
if ( ! empty( $block_editor_context->post ) ) {
|
||||||
$post = $block_editor_context->post;
|
$post = $block_editor_context->post;
|
||||||
|
|
||||||
|
@ -440,6 +443,7 @@ function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont
|
||||||
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
* @param WP_Block_Editor_Context $block_editor_context The current block editor context.
|
||||||
*/
|
*/
|
||||||
$preload_paths = apply_filters( 'block_editor_rest_api_preload_paths', $preload_paths, $block_editor_context );
|
$preload_paths = apply_filters( 'block_editor_rest_api_preload_paths', $preload_paths, $block_editor_context );
|
||||||
|
|
||||||
if ( ! empty( $block_editor_context->post ) ) {
|
if ( ! empty( $block_editor_context->post ) ) {
|
||||||
$selected_post = $block_editor_context->post;
|
$selected_post = $block_editor_context->post;
|
||||||
|
|
||||||
|
@ -479,6 +483,8 @@ function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset( $path );
|
||||||
|
|
||||||
$preload_data = array_reduce(
|
$preload_data = array_reduce(
|
||||||
$preload_paths,
|
$preload_paths,
|
||||||
'rest_preload_api_request',
|
'rest_preload_api_request',
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.9-beta1-52321';
|
$wp_version = '5.9-beta1-52322';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue