Missing explicit "parent table" field in tt_content causes duplication of content elements inside of repetitions with same ID and fieldname
nitori opened this issue · 3 comments
Mask Setup:
Two repetitions (with different namens), and each one containing a "content element" field with the same name. There is no error indicating that having the same name can cause issues (though an error appears if I try to use the same name in a different Mask element again):
If you then add two repetition elements that end up having the same ID (e.g. id=1 if it's the first element each), and add a content element to either of them, it get's duplicated to the other field both in backend as well in the frontend:
I think the primary issue is that nested content elements don't have a "parenttable" field, like nested repetitions have. There is only a corresponding "parentid" field, with the table name seemingly implied through the fieldname.
Example:
In the above example, the ID to the parent is stored in: tx_mask_content_elements_parent
which implies the field tx_mask_content_elements
that can both be found in the configuration for tables mask_repeat_1
and mask_repeat_2
.
Additionally it's impossible to know which repetition a tt_content element is assigned to, without having to load the entire mask configuration, due to the fact there is no explicit "parent table" field.
Which was the reason I even found that issues, due to a need to "go up the hierarchy" from a nested content element up through it's parents.
(ke_search likes to index tt_content elements inside of mask elements, even though the mask repetition it's inside of is disabled 😸).
Meaning: I needed a way to know if a content element is disabled implicitly due to a disabled parent repetition/content element. An explicit field for the table name (like it's done with repetitions) would probably solve the issue above and mine as well.
Greetings
Nitori
Hi Lars, thanks for your detailed bug report! I will be away for 3 weeks, so I can't fix it immediately. If you could provide a PR I would be very glad. Otherwise this needs to wait a bit.
I created a PR with a first draft. This also enables to share Content fields!
A migration wizard is still missing. Also, I need to make sure the recursive resolving works as before.
I will do a release of Mask 8.1 on Tuesday. Please try it out then.