Issue Bug New Stale

#83433selectMultipleSideBySide allow items mutiple times

Stephan Bauer 12/27/17, 13:54 updated 09/02/26, 13:21

Description

I made a TCA config to allow items mutiple times via the option ‘multiple’ => 1.

The config looks like this:

'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_testmultiple_domain_model_condition',
'MM' => 'tx_testmultiple_test_condition_mm',
'MM_hasUidField' => true,
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 1,

In the backend I can add items multiple times but when I’m trying to get all items in the frontend all duplicate items are removed.
Is this a bug or do I need additional configurations?

I made a litte extension for testing:
http://hosting8098.af933.netcup.net/test/test_multiple_1.0.0_201712271223.zip
Same problem exists in TYPO3 7.6 also.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] selectMultipleSideBySide allow items mutiple times Resolves: #83433 Releases: main

Files 2

History 2

  1. Georg Ringer commented <span data-processor="relativetime" data-value="2026-09-02T13:21:58+00:00" > 09/02/26, 13:21 </span>

    AI analyze
    —

    Still reproducible on main (v15).

    Note upfront: MM_hasUidField is deprecated since v13, the flag driving this is
    ’multiple’ => 1 nowadays (see DefaultTcaSchema, which then adds the uid column
    and drops the uid_local/uid_foreign primary key).

    I built a fixture with a select/MM field carrying ‘multiple’ => 1 and three MM
    rows (tag 1 twice, tag 2 once) and measured each layer:

    MM table                                3 rows   ok
    RelationHandler::readMM() -> itemArray 3 items ok
    Extbase SQL / QueryResult 3 rows ok
    … distinct object instances 2 lost
    resulting ObjectStorage 2 lost

    So the SQL side is fine – the duplicate row is fetched. The records are dropped
    afterwards, by two mechanisms that sit on top of each other:

    1. Identity map. DataMapper::mapSingleRow() asks the persistence session for an
    already registered object of that class/uid and returns the very same
    instance for the second row. Three rows collapse into two objects.

    2. ObjectStorage. mapResultToPropertyValue() attaches those objects into an
    ObjectStorage, which is keyed by spl_object_hash. Attaching the same instance
    twice just overwrites the entry. That is intentional – the class documents
    itself as “It ensures the uniqueness of an object in the storage.”

    Why this is not a trivial fix: both mechanisms are load-bearing, not incidental.

    - Dropping the identity map (one instance per record) would break dirty tracking
    and the persistence session as a whole.
    - Turning ObjectStorage into a multiset touches count(), detach(), contains(),
    _memorizeCleanState()/_isDirty(), the addedObjectsPositions bookkeeping, and
    the write path in Backend::persistObjectStorage(), which assigns exactly one
    sorting position and one MM row per contained object. That is a breaking
    change across the whole persistence layer.

    In other words: this is less “Extbase gets it wrong in one spot” and more “the
    Extbase domain model cannot represent the same record twice in one relation”.

    Workaround for anyone hitting this: model the relation with a real intermediate
    entity (type=inline with its own uid) instead of MM + multiple. The intermediate
    records have distinct uids, so they map to distinct objects and everything -
    reading, sorting, persisting – works as expected.