Issue Bug Closed

#23980Relations with MM_opposite_field don't update the relation count of opposite field

Kevin Ulrich Moschallski 11/07/10, 17:24 updated 06/03/25, 19:35

Description

I use this config in TCA for symmetric relations between two tables:

Local side:

‘config’ => array(
‘type’ => ‘group’,
‘internal_type’ => ‘db’,
‘allowed’ => ‘tx_specialoffersmvc_domain_model_item’,
‘foreign_table’ => ‘tx_specialoffersmvc_domain_model_item’,
‘MM_opposite_field’ => ‘portals’,
‘MM’ => ‘tx_specialoffersmvc_portal_item_mm’,
‘MM_match_fields’ => array(
‘tablenames’ => ‘tx_specialoffersmvc_domain_model_portal’
),
‘size’ => 5,
‘maxitems’ => 9999
)

Foreign side:

‘config’ => array(
‘type’ => ‘group’,
‘internal_type’ => ‘db’,
‘allowed’ => ‘tx_specialoffersmvc_domain_model_portal’,
‘MM_match_fields’ => array(‘tablenames’ => ‘tx_specialoffersmvc_domain_model_portal’),
‘foreign_table’ => ‘tx_specialoffersmvc_domain_model_portal’,
‘foreign_field’ => ‘items’,
‘prepend_tname’ => 1,
‘size’ => 5,
‘maxitems’ => 9999,
‘MM’ => ‘tx_specialoffersmvc_portal_item_mm’,
)

The realation works fine but the field values aren’t updated correctly.

I found this in the mailing list:

http://lists.typo3.org/pipermail/typo3-dev/2010-February/038917.html

Franz Koch gave me the right posision to fix this. Unfortunately his approach with the TCEMain_postProc wasn’t availible anymore on the pastbin page.

So i tried to fix it in the core. I’ll append a patch for review. The patch is against TYPO3 4.4.4

(issue imported from #M16294)

Reviews 0

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

Files 2

History 13

  1. Franz Koch commented <span data-processor="relativetime" data-value="2010-11-13T10:49:11+00:00" > 11/13/10, 10:49 </span>

    I attached my hook workaround so that it doesn’t get lost again like on pastbin.

  2. Nabil Saleh commented and changed target version <span data-processor="relativetime" data-value="2012-05-23T16:59:50+00:00" > 05/23/12, 16:59 </span>

    This bug has great impact on extbase relationmapping too as extbase expects the “relation”-field for the mm relation to be !== null (see datamapper) and otherwise does not fetch related records. Also One might have a look at http://forge.typo3.org/issues/32549

  3. Thomas Deinhamer commented <span data-processor="relativetime" data-value="2012-06-13T01:46:14+00:00" > 06/13/12, 01:46 </span>

    This also happens on 6.0.0-dev on PHP 5.4.3.

    Nabil Saleh is also right about Extbase, which
    won’t find the relation and returns NULL/0 when
    using a repository and/or a query object.

  4. Thomas Deinhamer commented <span data-processor="relativetime" data-value="2012-06-13T01:50:54+00:00" > 06/13/12, 01:50 </span>

    If the record is edited from the local side (the field without the “opposite field” configuration),
    the “count” seems to be set correctly and Extbase will find the record, so I think #32549
    may be already fixed – mind: I’m using Extbase 6.0.0-dev with the new property mapper enabled.

  5. Mathias Schreiber changed description category target version Is Regression 0 <span data-processor="relativetime" data-value="2015-01-09T12:47:39+00:00" > 01/09/15, 12:47 </span>

  6. Oliver Hader commented and changed priority Should have Could have <span data-processor="relativetime" data-value="2017-11-14T17:21:51+00:00" > 11/14/17, 17:21 </span>

    sys_category is a very good and generic example. For instance adding a new category to e.g. pages.category field should as a result also update also sys_category records that a references in the MM table. Implementing this opposite look-up and update might really become a nightmare.

    If the problem is Extbase only, I’d rather suggest to take the additional MM join on the database level.

  7. Adrian Rudnik commented <span data-processor="relativetime" data-value="2023-10-04T10:48:21+00:00" > 10/04/23, 10:48 </span>

    I’m currently trying to index documents that are related through a common m:n relationship. As this is not triggered through the processmap thingies, what would be the best way to catch these kind of changes?

  8. Christian Kuhn commented and changed status Accepted Closed <span data-processor="relativetime" data-value="2025-06-03T19:35:11+00:00" > 06/03/25, 19:35 </span>

    hey.

    i’ll have to put an end to this extremely old issue now: The “count” fields are a doomed approach for a long while already. they represent a poor man db de-normalization. various areas in the framework have the tendency to not properly update the field, extbase for example usually does not care at all.

    with MM in particular, the count fields also have logical conflicts when workspaces are involved since sometimes foreign or local side records are not workspace-overlayed while others are. this by definition leads to wrong counts since those rows may be double used (for live and for workspaces) and have different number of opposite rows attached.

    i’m planning to get rid of the fields for a while already. we’ll not try to fix them, but try to remove them instead.