Skip to content

Commit

Permalink
Handle another illegal array access in the tl_page DCA (see contao#2794)
Browse files Browse the repository at this point in the history
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes -
| Docs PR or issue | -

This fixes `Warning: Undefined array key "root"` coming from `DCTable` line 3669. This also hardens `tl_page#pastePage()` that will receive an incomplete `$row` by the call in line 3678 and would otherwise produce `Warning: Undefined array key "pid"`.

https://github.com/contao/contao/blob/1873bcc9ea728a08ca8755f6e7251d999d7b316b/core-bundle/src/Resources/contao/drivers/DC_Table.php#L3669-L3690

Commits
-------

7e5b39f handle illegal array access
5ff8b5f simplify expression

Co-authored-by: Leo Feyer <github@contao.org>
  • Loading branch information
2 people authored and fritzmg committed Mar 4, 2021
1 parent f16cbfc commit 51107f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/contao/dca/tl_page.php
Expand Up @@ -1461,7 +1461,7 @@ public function pastePage(DataContainer $dc, $row, $table, $cr, $arrClipboard=nu
}

// Prevent adding non-root pages on top-level
if ($row['pid'] == 0 && Input::get('mode') != 'create')
if (empty($row['pid']) && Input::get('mode') != 'create')
{
$objPage = $this->Database->prepare("SELECT * FROM " . $table . " WHERE id=?")
->limit(1)
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/contao/drivers/DC_Table.php
Expand Up @@ -3667,7 +3667,7 @@ protected function treeView()
$_buttons = '&nbsp;';

// Show paste button only if there are no root records specified
if ($blnClipboard && ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] ?? null) == 5 && ((empty($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) && $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] !== false) || ($GLOBALS['TL_DCA'][$table]['list']['sorting']['rootPaste'] ?? null)) && Input::get('act') != 'select')
if ($blnClipboard && ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] ?? null) == 5 && ((empty($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) && ($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] ?? null) !== false) || ($GLOBALS['TL_DCA'][$table]['list']['sorting']['rootPaste'] ?? null)) && Input::get('act') != 'select')
{
// Call paste_button_callback (&$dc, $row, $table, $cr, $childs, $previous, $next)
if (\is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['paste_button_callback'] ?? null))
Expand Down

0 comments on commit 51107f0

Please sign in to comment.