From ef335edfdf62c1199909ed91c273a67c8fd454c3 Mon Sep 17 00:00:00 2001 From: Leo Feyer <1192057+leofeyer@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:20:32 +0100 Subject: [PATCH] Also check the ptable in the SQL query --- core-bundle/contao/library/Contao/Controller.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core-bundle/contao/library/Contao/Controller.php b/core-bundle/contao/library/Contao/Controller.php index 8d051f327be..58eaa71a8bc 100644 --- a/core-bundle/contao/library/Contao/Controller.php +++ b/core-bundle/contao/library/Contao/Controller.php @@ -1282,11 +1282,20 @@ protected function getParentEntries($strTable, $intId) do { + $dynamicWhere = ''; + $values = array($intId); + + if ($GLOBALS['TL_DCA'][$strParentTable]['config']['dynamicPtable']) + { + $dynamicWhere = ' AND ptable=?'; + $values[] = $strParentTable; + } + // Get the pid $objParent = $db - ->prepare("SELECT pid FROM " . $strParentTable . " WHERE id=?") + ->prepare("SELECT pid FROM " . $strParentTable . " WHERE id=?$dynamicWhere") ->limit(1) - ->execute($intId); + ->execute(...$values); if ($objParent->numRows < 1) {