Project

General

Profile

Actions

Bug #91304

open

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

Added by Georgi Mateev almost 4 years ago. Updated over 3 years ago.

Status:
New
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 3 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

Also available in: Atom PDF