[BUGFIX] Get only valid template records in backend -> Template -> PID 0 72/58472/5
authorIoulia Kondratovitch <ik@plan2.net>
Sat, 29 Sep 2018 18:41:01 +0000 (20:41 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 5 Dec 2018 17:32:50 +0000 (18:32 +0100)
Get only template records, where corresponding parent page really exists
in the database.

Resolves: #86453
Releases: 8.7
Change-Id: Ie9d403fd3979ae76d1192ccd39408310d8938e8d
Reviewed-on: https://review.typo3.org/58472
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Kummer <typo3@enobe.de>
Tested-by: Joerg Kummer <typo3@enobe.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php

index e6e95dd..183f23a 100644 (file)
@@ -220,20 +220,21 @@ class TypoScriptTemplateModuleController extends BaseScriptClass
             );
             $result = $queryBuilder
                 ->select(
-                    'uid',
-                    'pid',
-                    'title',
-                    'sitetitle',
-                    'root',
-                    'hidden',
-                    'starttime',
-                    'endtime',
-                    't3ver_oid',
-                    't3ver_wsid',
-                    't3ver_state',
-                    't3ver_move_id'
+                    'sys_template.uid',
+                    'sys_template.pid',
+                    'sys_template.title',
+                    'sys_template.sitetitle',
+                    'sys_template.root',
+                    'sys_template.hidden',
+                    'sys_template.starttime',
+                    'sys_template.endtime',
+                    'sys_template.t3ver_oid',
+                    'sys_template.t3ver_wsid',
+                    'sys_template.t3ver_state',
+                    'sys_template.t3ver_move_id'
                 )
                 ->from('sys_template')
+                ->join('sys_template', 'pages', 'pages', $queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('sys_template.pid')))
                 ->orderBy('sys_template.pid')
                 ->addOrderBy('sys_template.sorting')
                 ->execute();
@@ -718,11 +719,11 @@ page.10.value = HELLO WORLD!
         }
         $queryBuilder->andWhere(
             $queryBuilder->expr()->in(
-                't3ver_wsid',
+                $tableName . '.t3ver_wsid',
                 $queryBuilder->createNamedParameter($workspaceIds, Connection::PARAM_INT_ARRAY)
             ),
             $queryBuilder->expr()->neq(
-                'pid',
+                $tableName . '.pid',
                 $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)
             )
         );