[BUGFIX] TCA: Make ###CURRENT_PID### work in foreign_table_where in IRRE 65/51865/2
authorNicole Cordes <typo3@cordes.co>
Mon, 12 Dec 2016 16:53:10 +0000 (17:53 +0100)
committerNicole Cordes <typo3@cordes.co>
Sun, 26 Feb 2017 23:01:14 +0000 (00:01 +0100)
The patch adds the current database row to the data passed to the select
field rendered by foreign_selector of IRRE.
This data is necessary to properly resolve the ###CURRENT_PID### marker
in a foreign_table_where clause.

Resolves: #78960
Releases: master, 7.6
Change-Id: I17f6b4a78d20c101ef7caab227d23c87f138e8ce
Reviewed-on: https://review.typo3.org/51865
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php

index f5a0239..534f74a 100644 (file)
@@ -1022,11 +1022,14 @@ abstract class AbstractItemProvider
                 }
                 $foreignTableClause = implode('', $whereClauseParts);
             }
-            // Use pid from parent page clause if in flex flom context
-            if (strpos($foreignTableClause, '###CURRENT_PID###') !== false
-                && !empty($result['flexParentDatabaseRow']['pid'])
-            ) {
-                $effectivePid = $result['flexParentDatabaseRow']['pid'];
+            if (strpos($foreignTableClause, '###CURRENT_PID###') !== false) {
+                // Use pid from parent page clause if in flex form context
+                if (!empty($result['flexParentDatabaseRow']['pid'])) {
+                    $effectivePid = $result['flexParentDatabaseRow']['pid'];
+                // Use pid from database row if in inline context
+                } elseif (!$effectivePid && !empty($result['databaseRow']['pid'])) {
+                    $effectivePid = $result['databaseRow']['pid'];
+                }
             }
 
             $siteRootUid = 0;
index 3210f74..1664bb0 100644 (file)
@@ -252,6 +252,7 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
                 // do extra handling of pageTsConfig merged here. Just provide "parent" pageTS as is
                 'pageTsConfig' => $result['pageTsConfig'],
                 'userTsConfig' => $result['userTsConfig'],
+                'databaseRow' => $result['databaseRow'],
                 'processedTca' => [
                     'ctrl' => [],
                     'columns' => [