#66574Relations of definitions using MM_opposite_field are missing in ReferenceIndex
Description
Consider this TCA definition:
$TCA['tx_myext_a']['columns'] = array(
'x' => array(
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_myext_b',
'MM' => 'tx_myext_a_b_mm',
)
),
);
$TCA['tx_myext_b']['columns'] = array(
'y' => array(
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_myext_a',
'MM' => 'tx_myext_a_b_mm',
'MM_opposite_field' => 'x',
)
),
);
References are found and created in sys_refindex by ReferenceIndex->getRelations_procDB() but only for one side:
sys_refindex contains records with tablename “tx_myext_a” being shown as references in web_list if you look at table tx_myext_b
array(12) {
["tablename"]=>
string(16) "tx_myext_a"
["recuid"]=>
int(5)
["field"]=>
string(1) "x"
["flexpointer"]=>
string(0) ""
["softref_key"]=>
string(0) ""
["softref_id"]=>
string(0) ""
["sorting"]=>
int(1)
["deleted"]=>
int(0)
["workspace"]=>
int(0)
["ref_table"]=>
string(12) "tx_myext_b"
["ref_uid"]=>
string(4) "4544"
["ref_string"]=>
string(0) ""
}
but the references for tx_myext_b shown in tx_myext_a are missing.
This is due to ReferenceIndex->getRelations_procDB()
public function getRelations_procDB($value, $conf, $uid, $table = '', $field = '') {
// Get IRRE relations
if (empty($conf)) {
return FALSE;
} elseif ($conf['type'] === 'inline' && !empty($conf['foreign_table']) && empty($conf['MM'])) {
$dbAnalysis = $this->getRelationHandler();
$dbAnalysis->setUseLiveReferenceIds(FALSE);
$dbAnalysis->start($value, $conf['foreign_table'], '', $uid, $table, $conf);
return $dbAnalysis->itemArray;
// DB record lists:
} elseif ($this->isDbReferenceField($conf)) {
$allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
if ($conf['MM_opposite_field']) {
return array();
}
$dbAnalysis = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
$dbAnalysis->start($value, $allowedTables, $conf['MM'], $uid, $table, $conf);
return $dbAnalysis->itemArray;
If there is a definition in ‘MM_opposite_field’, an empty array is returned instead of the relations.