PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | classes/image/image-restore.php +15 -4 1.7.4 → trunk View file →
@@ -23,9 +23,9 @@
23 23 foreach ( $image_ids as $image_id ) {
24 24 try {
25 25 self::restore( $image_id, $keep_image_meta );
26 26 } catch ( Throwable $t ) {
27 - Logger::log( Logger::LEVEL_ERROR, 'Bulk images restoring error: ' . $t->getMessage() );
27 + Logger::error( 'Bulk images restoring error: ' . $t->getMessage() );
28 28
29 29 ( new Image_Meta( $image_id ) )
30 30 ->set_status( Image_Status::RESTORING_FAILED )
31 31 ->save();
@@ -52,16 +52,27 @@
52 52 $backup_path = $meta->get_image_backup_path( $image_size );
53 53 $current_path = $image->get_file_path( $image_size );
54 54
55 55 if ( $backup_path && $current_path ) {
56 - $original_path = self::get_path_from_backup_path( $backup_path );
56 + $resolved_backup_path = Image_Backup_Path_Validator::resolve( $backup_path );
57 57
58 - if ( $original_path === $backup_path ) {
58 + if ( null === $resolved_backup_path ) {
59 + Logger::warn(
60 + "Skipped restoring invalid backup path for image {$image_id} and size {$image_size}"
61 + );
62 +
63 + continue;
64 + }
65 +
66 + $original_path = self::get_path_from_backup_path( $resolved_backup_path );
67 +
68 + if ( $original_path === $resolved_backup_path ) {
69 +
59 70 File_System::delete( $current_path, false, 'f' );
60 71
61 72 self::update_posts( $current_path, $original_path );
62 73 } else {
63 - File_System::move( $backup_path, $original_path, $original_path === $current_path );
74 + File_System::move( $resolved_backup_path, $original_path, $original_path === $current_path );
64 75
65 76 if ( $original_path !== $current_path ) {
66 77 File_System::delete( $current_path, false, 'f' );
67 78