From e6073d532349bfc7c42e6fe3b0877e459a35abb6 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 1 Feb 2024 07:42:29 -0700 Subject: [PATCH] Ensure metadata is an array before proceeding. Remove code that isn't needed --- includes/Classifai/Features/ImageCropping.php | 4 +--- includes/Classifai/Providers/Azure/ComputerVision.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/includes/Classifai/Features/ImageCropping.php b/includes/Classifai/Features/ImageCropping.php index 777e4d0cd..c50c3965e 100644 --- a/includes/Classifai/Features/ImageCropping.php +++ b/includes/Classifai/Features/ImageCropping.php @@ -295,10 +295,8 @@ public function attachment_data_meta_box_content() { * @param int $attachment_id Attachment ID. */ public function maybe_crop_image( int $attachment_id ) { - $metadata = wp_get_attachment_metadata( $attachment_id ); - if ( clean_input( 'rescan-smart-crop' ) ) { - $result = $this->run( $attachment_id, 'crop', $metadata ); + $result = $this->run( $attachment_id, 'crop' ); if ( ! empty( $result ) && ! is_wp_error( $result ) ) { $meta = $this->save( $result, $attachment_id ); diff --git a/includes/Classifai/Providers/Azure/ComputerVision.php b/includes/Classifai/Providers/Azure/ComputerVision.php index 8ae0c33ef..0c0775a16 100644 --- a/includes/Classifai/Providers/Azure/ComputerVision.php +++ b/includes/Classifai/Providers/Azure/ComputerVision.php @@ -723,7 +723,7 @@ public function rest_endpoint_callback( $attachment_id, string $route_to_call = $metadata = wp_get_attachment_metadata( $attachment_id ); - if ( ! $metadata ) { + if ( ! $metadata || ! is_array( $metadata ) ) { return new WP_Error( 'invalid', esc_html__( 'No valid metadata found.', 'classifai' ) ); }