WPML
상태
해결됨
해결된 버전
WPML 4.6.4

문제 개요

Flywheel 호스팅이나 ImageMagick을 사용하는 경우, WordPress 라이브러리에 PDF를 업로드하면 치명적인 오류가 발생합니다:

PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /www/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-attachment-image-update.php:61

임시 해결 방법

  1. 사이트를 전체 백업하세요.
  2. /wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-attachment-image-update.php의 49-76번째 줄을 편집하세요.
  3. 변경 전:
    				if ( wp_image_editor_supports( array( 'mime_type' => $file['type'] ) ) ) {
    
    					$editor = wp_get_image_editor( $file['file'] );
    
    					if ( ! is_wp_error( $editor ) ) {
    
    						$size = $editor->get_size();
    						if ( $size['width'] > 150 || $size['height'] > 150 ) {
    							$resizing = $editor->resize( 150, 150, true );
    
    							if ( is_wp_error( $resizing ) ) {
    								wp_send_json_error( $resizing->get_error_message() );
    							}
    						}
    						$thumb = $editor->save();
    
    						if ( ! empty( $thumb ) ) {
    							$uploads_dir = wp_get_upload_dir();
    
    							$thumb_url  = $uploads_dir['baseurl'] . $uploads_dir['subdir'] . '/' . $thumb['file'];
    							$thumb_path = $thumb['path'];
    						}
    					} else {
    						wp_send_json_error( __( 'Failed to load the image editor', 'wpml-media' ) );
    					}
    				} elseif ( 0 === strpos( $file['type'], 'image/' ) ) {
    변경 후:
    				if ( wp_image_editor_supports( array( 'mime_type' => $file['type'] ) ) ) {
    
                        if ( ! extension_loaded( 'imagick' ) && ($file_array["type"] !== "application/pdf")) {
    
                            $editor = wp_get_image_editor($file['file']);
    
                            if (!is_wp_error($editor)) {
    
                                $size = $editor->get_size();
                                if ($size['width'] > 150 || $size['height'] > 150) {
                                    $resizing = $editor->resize(150, 150, true);
    
                                    if (is_wp_error($resizing)) {
                                        wp_send_json_error($resizing->get_error_message());
                                    }
                                }
                                $thumb = $editor->save();
    
                                if (!empty($thumb)) {
                                    $uploads_dir = wp_get_upload_dir();
    
                                    $thumb_url = $uploads_dir['baseurl'] . $uploads_dir['subdir'] . '/' . $thumb['file'];
                                    $thumb_path = $thumb['path'];
                                }
                            } else {
                                wp_send_json_error(__('Failed to load the image editor', 'wpml-media'));
                            }
                        }
    				} elseif ( 0 === strpos( $file['type'], 'image/' ) ) {

알려진 모든 문제 →