diff --git a/wp-includes/load.php b/wp-includes/load.php index 8c549d3660..9803590fc1 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -876,6 +876,7 @@ function wp_start_object_cache() { 'blog-lookup', 'blog_meta', 'global-posts', + 'image_editor', 'networks', 'network-queries', 'sites', diff --git a/wp-includes/media.php b/wp-includes/media.php index e16e5c7ff3..56389c5e14 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -4191,7 +4191,22 @@ function _wp_image_editor_choose( $args = array() ) { * 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'. */ $implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); - $supports_input = false; + + $editors = wp_cache_get( 'wp_image_editor_choose', 'image_editor' ); + + if ( ! is_array( $editors ) ) { + $editors = array(); + } + + // Cache the chosen editor implementation based on specific args and available implementations. + $cache_key = md5( serialize( array( $args, $implementations ) ) ); + + if ( isset( $editors[ $cache_key ] ) ) { + return $editors[ $cache_key ]; + } + + // Assume no support until a capable implementation is identified. + $editor = false; foreach ( $implementations as $implementation ) { if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) { @@ -4225,15 +4240,20 @@ function _wp_image_editor_choose( $args = array() ) { * This implementation supports the input type but not the output type. * Keep looking to see if we can find an implementation that supports both. */ - $supports_input = $implementation; + $editor = $implementation; continue; } // Favor the implementation that supports both input and output mime types. - return $implementation; + $editor = $implementation; + break; } - return $supports_input; + $editors[ $cache_key ] = $editor; + + wp_cache_set( 'wp_image_editor_choose', $editors, 'image_editor', DAY_IN_SECONDS ); + + return $editor; } /** diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 2cf6d2390a..724c4ad7d2 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -554,6 +554,7 @@ function switch_to_blog( $new_blog_id, $deprecated = null ) { 'blog-lookup', 'blog_meta', 'global-posts', + 'image_editor', 'networks', 'network-queries', 'sites', @@ -648,6 +649,7 @@ function restore_current_blog() { 'blog-lookup', 'blog_meta', 'global-posts', + 'image_editor', 'networks', 'network-queries', 'sites', diff --git a/wp-includes/version.php b/wp-includes/version.php index c9dabf58ff..4722082908 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-beta1-59188'; +$wp_version = '6.7-beta1-59189'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.