From 33ef0a3a1e0a6a1bfe01c5b0f67fb9856d5a7c7d Mon Sep 17 00:00:00 2001 From: Ralf Baussenwein Date: Thu, 19 Jan 2023 14:39:10 +0100 Subject: [PATCH] Optimize the delete process --- src/Driver.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Driver.php b/src/Driver.php index 903b57a..8003e25 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -1126,6 +1126,11 @@ public function deleteChilds($table, $id, &$delete) { parent::deleteChilds($table, $id, $delete); + // Do not delete record if it is not a multilingual dataContainer + if ('Multilingual' !== $GLOBALS['TL_DCA'][$table]['config']['dataContainer']) { + return; + } + // Do not delete record if there is no parent table if (empty($GLOBALS['TL_DCA'][$table]['config']['ptable'])) { return; @@ -1252,6 +1257,18 @@ protected function handleLanguageOperation() } elseif ($this->strTable === $request->request->get('FORM_SUBMIT') && $request->request->has('deleteLanguage') ) { + // Trigger the ondelete_callback + if (\is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['ondelete_callback'])) { + foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['ondelete_callback'] as $callback) { + if (\is_array($callback)) { + $this->import($callback[0]); + $this->{$callback[0]}->{$callback[1]}($this, ''); + } elseif (\is_callable($callback)) { + $callback($this, ''); + } + } + } + Database::getInstance() ->prepare( "DELETE FROM " . $this->strTable . " @@ -1268,6 +1285,7 @@ protected function handleLanguageOperation() if ($needsReload) { $_SESSION['TL_INFO'] = ''; + Message::reset(); Controller::reload(); } }