Project

General

Profile

Actions

Bug #91304

closed

CropVariantCollection doesn't iterate over the crop variants correctly when creating the collection

Added by Georgi Mateev over 4 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Image Cropping
Target version:
-
Start date:
2020-05-05
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In the create() method there is the following code:

reset($persistedCollectionConfig);
                foreach ($tcaConfig as $id => &$cropVariantConfig) {
                    if (!isset($persistedCollectionConfig[$id])) {
                        $id = key($persistedCollectionConfig);
                        next($persistedCollectionConfig);
                    }
                    if (isset($persistedCollectionConfig[$id]['cropArea'])) {
                        $cropVariantConfig['cropArea'] = $persistedCollectionConfig[$id]['cropArea'];
                    }
                    if (isset($persistedCollectionConfig[$id]['focusArea'], $cropVariantConfig['focusArea'])) {
                        $cropVariantConfig['focusArea'] = $persistedCollectionConfig[$id]['focusArea'];
                    }
                    if (isset($persistedCollectionConfig[$id]['selectedRatio'], $cropVariantConfig['allowedAspectRatios'][$persistedCollectionConfig[$id]['selectedRatio']])) {
                        $cropVariantConfig['selectedRatio'] = $persistedCollectionConfig[$id]['selectedRatio'];
                    }
                }

The next() call is useless and leads to the iteration fetching wrong cofiguration data should there be more than 2 cropVariants.


Files

Actions #1

Updated by Kevin Ditscheid over 4 years ago

I can not reproduce the underlying issue anymore.

Original Problem description:


Removes an unnecessary line of code in the CropVariantCollection::create() method that leads to broken configuration
when there are more than 2 cropVariants.
To reproduce this:
- Open the image editor, edit the cropping areas and save them.
- Then add new cropVariants in the TCA Configuration.
- This will lead to the situation where you have configured crop variants that have don't exist in the database values
(This is where the bug starts. You can reach this point in other ways but this was the most straightforward to explain)
- Open the image editing in the Backend
- You will see that the cropVariants with no values will get random cropping areas from the other cropVariants (or no
cropArea at all)
I fixed this to always fall back to the first cropArea when there is no value (usually default)

Actions #2

Updated by Garvin Hicking 5 months ago

  • Status changed from New to Closed

This seems to have been fixed meanwhile. I will close this issue for now, if you feel this is a mistake or have additional feedback, please get in touch. You can also create a follow-up issue. Thanks for the report!

Actions

Also available in: Atom PDF