From c596c9b1c2aca7c845d4de02f8bfaa4dd108e8ba Mon Sep 17 00:00:00 2001 From: David Greminger Date: Thu, 16 Jul 2020 17:04:25 +0200 Subject: [PATCH 1/2] Fix comment (see #1938) Description ----------- | Q | A | -----------------| --- | Fixed issues | n/a | Docs PR or issue | n/a Caution: It's nitpicking! I've just stumbled over this ... Commits ------- 52ac3989 Fix comment --- faq-bundle/src/Resources/contao/dca/tl_user.php | 2 +- news-bundle/src/Resources/contao/dca/tl_user.php | 2 +- newsletter-bundle/src/Resources/contao/dca/tl_user.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/faq-bundle/src/Resources/contao/dca/tl_user.php b/faq-bundle/src/Resources/contao/dca/tl_user.php index 6f1eb36c881..36025f19f23 100644 --- a/faq-bundle/src/Resources/contao/dca/tl_user.php +++ b/faq-bundle/src/Resources/contao/dca/tl_user.php @@ -16,7 +16,7 @@ ->applyToPalette('custom', 'tl_user') ; -// Add fields to tl_user_group +// Add fields to tl_user $GLOBALS['TL_DCA']['tl_user']['fields']['faqs'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_user']['faqs'], diff --git a/news-bundle/src/Resources/contao/dca/tl_user.php b/news-bundle/src/Resources/contao/dca/tl_user.php index bb7ce266f24..30522af954a 100644 --- a/news-bundle/src/Resources/contao/dca/tl_user.php +++ b/news-bundle/src/Resources/contao/dca/tl_user.php @@ -16,7 +16,7 @@ ->applyToPalette('custom', 'tl_user') ; -// Add fields to tl_user_group +// Add fields to tl_user $GLOBALS['TL_DCA']['tl_user']['fields']['news'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_user']['news'], diff --git a/newsletter-bundle/src/Resources/contao/dca/tl_user.php b/newsletter-bundle/src/Resources/contao/dca/tl_user.php index f06cc89aeb6..a8196c4d6d0 100644 --- a/newsletter-bundle/src/Resources/contao/dca/tl_user.php +++ b/newsletter-bundle/src/Resources/contao/dca/tl_user.php @@ -16,7 +16,7 @@ ->applyToPalette('custom', 'tl_user') ; -// Add fields to tl_user_group +// Add fields to tl_user $GLOBALS['TL_DCA']['tl_user']['fields']['newsletters'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_user']['newsletters'], From ba9ea6cbc85cd2a819a86f0a5366f54840ad9f7d Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Tue, 21 Jul 2020 09:32:56 +0200 Subject: [PATCH 2/2] Add useful exception when hook class is invalid/missing (see #1949) Description ----------- If an invalid class is imported, we'd always get `Warning: in_array() expects parameter 2 to be array, null given` because `get_class_methods()` returns null instead of an array. Commits ------- 1cf46e66 Add useful exception when hook class is invalid/missing d5bc83c0 CS --- .../src/Resources/contao/library/Contao/System.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core-bundle/src/Resources/contao/library/Contao/System.php b/core-bundle/src/Resources/contao/library/Contao/System.php index 9494a7e95bd..a81d5e51a81 100644 --- a/core-bundle/src/Resources/contao/library/Contao/System.php +++ b/core-bundle/src/Resources/contao/library/Contao/System.php @@ -161,6 +161,10 @@ protected function import($strClass, $strKey=null, $blnForce=false) { $this->arrObjects[$strKey] = $container->get($strClass); } + elseif (!class_exists($strClass)) + { + throw new \RuntimeException('System::import() failed because class "' . $strClass . '" is not a valid class name or does not exist.'); + } elseif (\in_array('getInstance', get_class_methods($strClass))) { $this->arrObjects[$strKey] = \call_user_func(array($strClass, 'getInstance')); @@ -202,6 +206,10 @@ public static function importStatic($strClass, $strKey=null, $blnForce=false) { static::$arrStaticObjects[$strKey] = $container->get($strClass); } + elseif (!class_exists($strClass)) + { + throw new \RuntimeException('System::importStatic() failed because class "' . $strClass . '" is not a valid class name or does not exist.'); + } elseif (\in_array('getInstance', get_class_methods($strClass))) { static::$arrStaticObjects[$strKey] = \call_user_func(array($strClass, 'getInstance'));