[FEATURE] Add possibility to define foreign_match_fields for IRRE inline relations.
authorIngmar Schlecht <ingmar@typo3.org>
Sat, 27 Aug 2011 13:01:03 +0000 (15:01 +0200)
committerTolleiv Nietsch <info@tolleiv.de>
Sat, 14 Jan 2012 15:40:25 +0000 (16:40 +0100)
This patch request adds the possibility to define foreign_match_fields (similar to MM_match_fields) for IRRE inline relations. This is required for the upcoming file abstraction layer in TYPO3.

Example:
'my_parent_fieldname' => array (
'config' => array (
'type' => 'inline',
'foreign_table' => 'tx_myext_childtable',
'foreign_field' => 'parent_record_pointer',
'foreign_match_fields' => array(
'parent_field_pointer' => 'my_parent_fieldname',
),
)
),

Change-Id: I6b97126dcf9704bd3f37bebda1a1f2f0213c9aa9
Fixes: #29296
Releases: 4.7
Reviewed-on: http://review.typo3.org/7669
Reviewed-by: Björn Pedersen
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
t3lib/class.t3lib_loaddbgroup.php

index 12912c3..c132726 100644 (file)
@@ -514,6 +514,7 @@ class t3lib_loadDBGroup {
                $foreign_table = $conf['foreign_table'];
                $foreign_table_field = $conf['foreign_table_field'];
                $useDeleteClause = $this->undeleteRecord ? FALSE : TRUE;
+               $foreign_match_fields = is_array($conf['foreign_match_fields']) ? $conf['foreign_match_fields'] : array();
 
                        // search for $uid in foreign_field, and if we have symmetric relations, do this also on symmetric_field
                if ($conf['symmetric_field']) {
@@ -531,6 +532,11 @@ class t3lib_loadDBGroup {
                        $whereClause .= ' AND ' . $foreign_table_field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->currentTable, $foreign_table);
                }
 
+                       // Add additional where clause if foreign_match_fields are defined
+               foreach ($foreign_match_fields as $field => $value) {
+                       $whereClause .= ' AND ' . $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $foreign_table);
+               }
+
                        // Select children in the same workspace:
                if (t3lib_BEfunc::isTableWorkspaceEnabled($this->currentTable) && t3lib_BEfunc::isTableWorkspaceEnabled($foreign_table)) {
                        $currentRecord = t3lib_BEfunc::getRecord($this->currentTable, $uid, 't3ver_wsid', '', $useDeleteClause);
@@ -589,6 +595,7 @@ class t3lib_loadDBGroup {
                $foreign_field = $conf['foreign_field'];
                $symmetric_field = $conf['symmetric_field'];
                $foreign_table_field = $conf['foreign_table_field'];
+               $foreign_match_fields = is_array($conf['foreign_match_fields']) ? $conf['foreign_match_fields'] : array();
 
                        // if there are table items and we have a proper $parentUid
                if (t3lib_utility_Math::canBeInterpretedAsInteger($parentUid) && count($this->tableArray)) {
@@ -622,7 +629,7 @@ class t3lib_loadDBGroup {
                                        $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $conf, $row);
                                }
 
-                               $updateValues = array();
+                               $updateValues = $foreign_match_fields;
                                $workspaceValues = array();
 
                                        // no update to the uid is requested, so this is the normal behaviour