From e1f1e8def9856742dcb9b0cfd1ee4cc7ebd3c7e0 Mon Sep 17 00:00:00 2001 From: "M. Vondano" Date: Thu, 4 Mar 2021 08:58:07 +0100 Subject: [PATCH] Fix an illegal array access in DC_Table when expanding the tree (see #2805) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description ----------- | Q | A | -----------------| --- | Fixed issues | Fixes #2797 | Docs PR or issue | - I split the PR in two commits: * one that *only* formats the code so that there is any chance of reviewing this: https://github.com/contao/contao/commit/a1a16fea1c1cae125f129f03e38db1a3abf5a59e * one that applies the fixes: https://github.com/contao/contao/commit/9bcedb793b74062b4e4cfddc7a30765694ffd5fe (If you want to, I can collapse the whole thing into a oneline-mega-expression again in a third oneā€¦) Commits ------- a1a16fea format call 9bcedb79 fix illegal array access 2f22b2fc collapse expression --- core-bundle/src/Resources/contao/drivers/DC_Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-bundle/src/Resources/contao/drivers/DC_Table.php b/core-bundle/src/Resources/contao/drivers/DC_Table.php index 7cbc268ba7b..4b5c16c22a7 100644 --- a/core-bundle/src/Resources/contao/drivers/DC_Table.php +++ b/core-bundle/src/Resources/contao/drivers/DC_Table.php @@ -3844,7 +3844,7 @@ public function ajaxTreeView($id, $level) for ($i=0, $c=\count($arrIds); $i<$c; $i++) { - $return .= ' ' . trim($this->generateTree($table, $arrIds[$i], array('p'=>$arrIds[($i-1)], 'n'=>$arrIds[($i+1)]), $hasSorting, $margin, ($blnClipboard ? $arrClipboard : false), ($id == $arrClipboard['id'] || (\is_array($arrClipboard['id']) && \in_array($id, $arrClipboard['id'])) || (!$blnPtable && !\is_array($arrClipboard['id']) && \in_array($id, $this->Database->getChildRecords($arrClipboard['id'], $table)))), $blnProtected)); + $return .= ' ' . trim($this->generateTree($table, $arrIds[$i], array('p'=>($arrIds[$i-1] ?? null), 'n'=>($arrIds[$i+1] ?? null)), $hasSorting, $margin, ($blnClipboard ? $arrClipboard : false), $arrClipboard !== null && ($id == $arrClipboard['id'] || (\is_array($arrClipboard['id']) && \in_array($id, $arrClipboard['id'])) || (!$blnPtable && !\is_array($arrClipboard['id']) && \in_array($id, $this->Database->getChildRecords($arrClipboard['id'], $table)))), $blnProtected)); } return $return;