mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
General: Use static
on closures whenever $this
is not used to avoid memory leaks.
Props westonruter, jrf, spacedmonkey. Fixes #58323. Built from https://develop.svn.wordpress.org/trunk@55822 git-svn-id: http://core.svn.wordpress.org/trunk@55334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8db8a24e46
commit
4c2394eed5
@ -2685,7 +2685,7 @@ function wp_opcache_invalidate_directory( $dir ) {
|
||||
* with sub-directories represented as nested arrays.
|
||||
* @param string $path Absolute path to the directory.
|
||||
*/
|
||||
$invalidate_directory = function( $dirlist, $path ) use ( &$invalidate_directory ) {
|
||||
$invalidate_directory = static function( $dirlist, $path ) use ( &$invalidate_directory ) {
|
||||
$path = trailingslashit( $path );
|
||||
|
||||
foreach ( $dirlist as $name => $details ) {
|
||||
|
@ -485,7 +485,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
||||
*
|
||||
* @return string Returns the block content.
|
||||
*/
|
||||
$settings['render_callback'] = function( $attributes, $content, $block ) use ( $template_path ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
||||
$settings['render_callback'] = static function( $attributes, $content, $block ) use ( $template_path ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
|
||||
ob_start();
|
||||
require $template_path;
|
||||
return ob_get_clean();
|
||||
|
@ -4826,7 +4826,7 @@ class WP_Query {
|
||||
* $value is passed by reference to allow it to be modified.
|
||||
* array_walk_recursive() does not return an array.
|
||||
*/
|
||||
function ( &$value ) use ( $wpdb, $placeholder ) {
|
||||
static function ( &$value ) use ( $wpdb, $placeholder ) {
|
||||
if ( is_string( $value ) && str_contains( $value, $placeholder ) ) {
|
||||
$value = $wpdb->remove_placeholder_escape( $value );
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) {
|
||||
// Check if there are attributes that are required.
|
||||
$required_attrs = array_filter(
|
||||
$allowed_html[ $element_low ],
|
||||
function( $required_attr_limits ) {
|
||||
static function( $required_attr_limits ) {
|
||||
return isset( $required_attr_limits['required'] ) && true === $required_attr_limits['required'];
|
||||
}
|
||||
);
|
||||
|
@ -792,7 +792,7 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
),
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => function ( $value ) {
|
||||
'sanitize_callback' => static function ( $value ) {
|
||||
return array_map( 'sanitize_html_class', wp_parse_list( $value ) );
|
||||
},
|
||||
),
|
||||
@ -873,7 +873,7 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
),
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'arg_options' => array(
|
||||
'sanitize_callback' => function ( $value ) {
|
||||
'sanitize_callback' => static function ( $value ) {
|
||||
return array_map( 'sanitize_html_class', wp_parse_list( $value ) );
|
||||
},
|
||||
),
|
||||
|
@ -534,7 +534,7 @@ class WP_REST_Menus_Controller extends WP_REST_Terms_Controller {
|
||||
),
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'arg_options' => array(
|
||||
'validate_callback' => function ( $locations, $request, $param ) {
|
||||
'validate_callback' => static function ( $locations, $request, $param ) {
|
||||
$valid = rest_validate_request_arg( $locations, $request, $param );
|
||||
|
||||
if ( true !== $valid ) {
|
||||
|
@ -2405,7 +2405,7 @@ function wp_common_block_scripts_and_styles() {
|
||||
function wp_filter_out_block_nodes( $nodes ) {
|
||||
return array_filter(
|
||||
$nodes,
|
||||
function( $node ) {
|
||||
static function( $node ) {
|
||||
return ! in_array( 'blocks', $node['path'], true );
|
||||
},
|
||||
ARRAY_FILTER_USE_BOTH
|
||||
@ -2635,7 +2635,7 @@ function enqueue_block_styles_assets() {
|
||||
if ( wp_should_load_separate_core_block_assets() ) {
|
||||
add_filter(
|
||||
'render_block',
|
||||
function( $html, $block ) use ( $block_name, $style_properties ) {
|
||||
static function( $html, $block ) use ( $block_name, $style_properties ) {
|
||||
if ( $block['blockName'] === $block_name ) {
|
||||
wp_enqueue_style( $style_properties['style_handle'] );
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.3-alpha-55821';
|
||||
$wp_version = '6.3-alpha-55822';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user