Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagick::queryFormats is slow, loaded on most admin pages #884

Open
joehoyle opened this issue Jun 26, 2024 · 0 comments
Open

Imagick::queryFormats is slow, loaded on most admin pages #884

joehoyle opened this issue Jun 26, 2024 · 0 comments

Comments

@joehoyle
Copy link
Member

wp_plupload_default_settings() calls:

	// Check if WebP images can be edited.
	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
		$defaults['webp_upload_error'] = true;
	}

	// Check if AVIF images can be edited.
	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
		$defaults['avif_upload_error'] = true;
	}

This in-turn does a Imagick::queryFormats per support, which is quite slow. E.g.

www-data@efddc66a02b9:/usr/src/app$ php -r '$start = microtime(true); var_dump( Imagick::queryFormats( "webp" ) ); var_dump( microtime( true ) - $start );'
array(0) {
}
float(0.0890190601348877)

This is pretty consistent. Given these is constant, I'm wondering if we could cache / hardcode this.

There doesn't appear to be any great hooks to be able to do that but might need more investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant