| @@ -658,11 +658,27 @@ | ||
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | if ( $is_nextgen_request ) { |
| 661 | 661 | $destination_path = $this->get_path_to_nextgen( $args['convert'] ); |
| 662 | - $this->path = $destination_path; | |
| 663 | - $this->file_type = null; | |
| 664 | - $this->editor = null; | |
| 662 | + | |
| 663 | + /* | |
| 664 | + * get_path_to_nextgen() returns false when the file is not an image, or when it | |
| 665 | + * already is in a next-gen format. Passing that along would hand an empty path to | |
| 666 | + * the filesystem, which throws an uncaught ValueError on PHP 8 and kills the | |
| 667 | + * background process mid-batch, leaving its lock behind and stalling the queue. | |
| 668 | + */ | |
| 669 | + if ( empty( $destination_path ) ) { | |
| 670 | + $this->filesystem->delete( $temp_file ); | |
| 671 | + | |
| 672 | + return new \WP_Error( | |
| 673 | + 'no_nextgen_destination', | |
| 674 | + __( 'Could not determine the destination path for the next-gen file.', 'imagify' ) | |
| 675 | + ); | |
| 676 | + } | |
| 677 | + | |
| 678 | + $this->path = $destination_path; | |
| 679 | + $this->file_type = null; | |
| 680 | + $this->editor = null; | |
| 665 | 681 | } else { |
| 666 | 682 | $destination_path = $this->path; |
| 667 | 683 | } |
| 668 | 684 | |