plan2net/webp

isFileInProcessingFolder issue

bernd-reindl opened this issue · 2 comments

In \Plan2net\Webp\EventListener\AfterFileProcessing the file is checked for isFileInProcessingFolder. If not in processing folder (this means the file wasn't changed) the original file is used for processing the webp image. But $processedFileWebp uses the configuration of $processedFile.

So it's possible that multiple database rows with same identifier but different configurations exist. And this leads to problems by ProcessedFileRepository->findByStorageAndIdentifier().

You can solve this by setting a blank configuration if isFileInProcessingFolder() returns false.

if (!$this->isFileInProcessingFolder($processedFile)) {
                // In this case the processed file has the wrong storage record attached
                // and the file would not be found in the next steps,
                // so we use the original file then
                $processedFile = $file;
                $configuration = [
                    'width' => null,
                    'height' => null,
                    'minWidth' => null,
                    'minHeight' => null,
                    'maxWidth' => null,
                    'maxHeight' => null,
                    'crop' => null
                ];
            }

But this has to be done before $processedFileWebp is created.

I attached the screenshot how to solve it.

webp1

My original file is 32x32. So the file isn't changed in both cases and the original file is used. But now there are two equal identifiers.

webp3

webp2

wazum commented

Thanks for the report, will take a look at it tomorrow

wazum commented

Fixed in current master, thanks