From b1a46c8708f93deebccd7421d43877acdc1e79af Mon Sep 17 00:00:00 2001 From: antpb Date: Fri, 14 Jun 2024 14:43:08 +0000 Subject: [PATCH] Media: Use `version_compare()` for Imagick version check when removing alpha. Previously `remove_pdf_alpha_channel()` used `Imagick::getVersion()` to validate the environment is capable of handling alpha. This was the incorrect function to use to check the module version as it will only provide the ImageMagick API version. This patch adjusts to instead use `phpversion()` as this is the correct method to get the Imagick version needed to determine alpha compatibility. This fixes a number of host tests that have been correctly failing on subsets of environments. Serendipidously, sometimes the API version was high enough to avoid shining light on this problem. Props swissspidy, joedolson, antpb. Fixes #60798. Built from https://develop.svn.wordpress.org/trunk@58415 git-svn-id: http://core.svn.wordpress.org/trunk@57864 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-image-editor-imagick.php | 3 +-- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index d38ee6fd63..eac302d7ce 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -775,9 +775,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { * @since 6.4.0 */ protected function remove_pdf_alpha_channel() { - $version = Imagick::getVersion(); // Remove alpha channel if possible to avoid black backgrounds for Ghostscript >= 9.14. RemoveAlphaChannel added in ImageMagick 6.7.5. - if ( $version['versionNumber'] >= 0x675 ) { + if ( version_compare( phpversion( 'imagick' ), '9.14', '>=' ) ) { try { // Imagick::ALPHACHANNEL_REMOVE mapped to RemoveAlphaChannel in PHP imagick 3.2.0b2. $this->image->setImageAlphaChannel( defined( 'Imagick::ALPHACHANNEL_REMOVE' ) ? Imagick::ALPHACHANNEL_REMOVE : 12 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 91a03450e0..7d93dce8ed 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-beta2-58414'; +$wp_version = '6.6-beta2-58415'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.