[Image gallery] Write inherited hotspot data to query table when saving parent#18855
Merged
robertSt7 merged 2 commits intopimcore:12.3from Jan 27, 2026
Merged
Conversation
Review Checklist
|
|
Contributor
|
@BlackbitDevs Thanks for fixing the hotspot inheritance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Steps to reproduce bug:
Test, enable inheritance, add an image gallery field namedimagesTestobject/parentTestobject/parent/child(so that it inherits data from/parent)/parent, add a hotspot, saveExpected behaviour:
Image gallery data gets inherited to the child object, thus in database table
object_query_Testthe columnimages__hotspotsthere is the same data for/parentand/parent/childActual behaviour:
Column
images__hotspotsonly gets filled for/parentbut not for/parent/child.After saving the child,
images__hotspotsis the same for both objects.Cause:
The place which is responsible for writing inherited data for the child objects to the query tables is
pimcore/models/DataObject/Concrete/Dao/InheritanceHelper.php
Lines 171 to 183 in 514e9ce
Here
getIdsToUpdateForValuefields()does not recognize the child column to be empty. There are multiple quirks here:pimcore/models/DataObject/Concrete/Dao/InheritanceHelper.php
Lines 524 to 525 in 514e9ce
$fieldnameisimages__hotspotsand sovalueis only the content of this column, not all columns which belong to image gallery data. But$this->fieldDefinitions[$fieldname]is aPimcore\Model\DataObject\ClassDefinition\Data\ImageGalleryobject. So the actual$valuedoes not match whatImageGallery::isEmpty()usually expects to get (aPimcore\Model\DataObject\Data\ImageGalleryobject ornull).$valueis the string"a:0:{}"because when saving an image gallery without hotspots, an empty array gets serialized inpimcore/models/DataObject/ClassDefinition/Data/ImageGallery.php
Line 118 in 514e9ce
So one way to solve the problem would be to add a check for
$data === "a:0:{}"inpimcore/models/DataObject/ClassDefinition/Data/ImageGallery.php
Lines 339 to 343 in 514e9ce
a:0:{}can get here).For this reason I decided for a different approach: When saving an image gallery without hotspots, we store
nullin the database. This way theImageGallery::isEmpty()will returntrueand thus the image gallery data in the query table gets updated when the parent gets saved.