[BUGFIX] Replace ###CURRENT_PID### with value from DB within FlexForms 30/48830/2
authorSteffen Müller <typo3@t3node.com>
Thu, 30 Jun 2016 11:05:36 +0000 (13:05 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 6 Jul 2016 16:43:45 +0000 (18:43 +0200)
Replace ###CURRENT_PID### in FlexForm context with values from
database. Within FlexForm context these values need to be
retrieved from the key flexParentDatabaseRow.

Resolves: #76888
Releases: master, 7.6
Change-Id: I5fd3cb0a18e41ae0d15cbb44556d05d88506a093
Reviewed-on: https://review.typo3.org/48830
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php

index d7c1b64..5cf1008 100644 (file)
@@ -959,6 +959,7 @@ abstract class AbstractItemProvider
     {
         $database = $this->getDatabaseConnection();
         $localTable = $result['tableName'];
+        $effectivePid = $result['effectivePid'];
 
         $foreignTableClause = '';
         if (!empty($result['processedTca']['columns'][$localFieldName]['config']['foreign_table_where'])
@@ -990,6 +991,12 @@ 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'];
+            }
 
             $siteRootUid = 0;
             foreach ($result['rootline'] as $rootlinePage) {
@@ -1042,7 +1049,7 @@ abstract class AbstractItemProvider
                     '###PAGE_TSCONFIG_STR###'
                 ],
                 [
-                    (int)$result['effectivePid'],
+                    (int)$effectivePid,
                     (int)$result['databaseRow']['uid'],
                     $siteRootUid,
                     $pageTsConfigId,
index ba61691..20e4872 100644 (file)
@@ -1323,6 +1323,15 @@ class TcaSelectItemsTest extends UnitTestCase
                 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=43',
                 [],
             ],
+            'replace CURRENT_PID within FlexForm' => [
+                'AND fTable.uid=###CURRENT_PID###',
+                'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=77',
+                [
+                    'flexParentDatabaseRow' => [
+                        'pid' => '77',
+                    ],
+                ],
+            ],
             'replace CURRENT_PID integer cast' => [
                 'AND fTable.uid=###CURRENT_PID###',
                 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.uid=431',