From 9857c3859f7bc07995995e78138b987997f42a2b Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Tue, 21 Jul 2020 11:29:09 +0200 Subject: [PATCH 1/3] Explicitly register the model classes --- .../src/Resources/contao/config/config.php | 10 +++++ .../src/Resources/contao/config/config.php | 8 ++++ .../src/Resources/contao/config/config.php | 41 ++++++++++++++++++- .../src/Resources/contao/config/config.php | 8 ++++ .../src/Resources/contao/config/config.php | 10 +++++ .../src/Resources/contao/config/config.php | 12 ++++++ 6 files changed, 88 insertions(+), 1 deletion(-) diff --git a/calendar-bundle/src/Resources/contao/config/config.php b/calendar-bundle/src/Resources/contao/config/config.php index f34a53e41d6..9a100917a63 100644 --- a/calendar-bundle/src/Resources/contao/config/config.php +++ b/calendar-bundle/src/Resources/contao/config/config.php @@ -9,6 +9,9 @@ */ use Contao\Calendar; +use Contao\CalendarEventsModel; +use Contao\CalendarFeedModel; +use Contao\CalendarModel; use Contao\ListWizard; use Contao\ModuleCalendar; use Contao\ModuleEventlist; @@ -52,3 +55,10 @@ $GLOBALS['TL_PERMISSIONS'][] = 'calendarp'; $GLOBALS['TL_PERMISSIONS'][] = 'calendarfeeds'; $GLOBALS['TL_PERMISSIONS'][] = 'calendarfeedp'; + +// Models +$GLOBALS['TL_MODELS'] = array( + 'tl_calendar_events' => CalendarEventsModel::class, + 'tl_calendar_feed' => CalendarFeedModel::class, + 'tl_calendar' => CalendarModel::class +); diff --git a/comments-bundle/src/Resources/contao/config/config.php b/comments-bundle/src/Resources/contao/config/config.php index c52d20dfb07..5e096fb7985 100644 --- a/comments-bundle/src/Resources/contao/config/config.php +++ b/comments-bundle/src/Resources/contao/config/config.php @@ -9,6 +9,8 @@ */ use Contao\Comments; +use Contao\CommentsModel; +use Contao\CommentsNotifyModel; use Contao\ContentComments; use Contao\ModuleComments; @@ -27,3 +29,9 @@ // Cron jobs $GLOBALS['TL_CRON']['daily']['purgeCommentSubscriptions'] = array(Comments::class, 'purgeSubscriptions'); + +// Models +$GLOBALS['TL_MODELS'] = array( + 'tl_comments' => CommentsModel::class, + 'tl_comments_notify' => CommentsNotifyModel::class +); diff --git a/core-bundle/src/Resources/contao/config/config.php b/core-bundle/src/Resources/contao/config/config.php index d8b2c44d91c..b76f468bbcb 100644 --- a/core-bundle/src/Resources/contao/config/config.php +++ b/core-bundle/src/Resources/contao/config/config.php @@ -8,6 +8,7 @@ * @license LGPL-3.0-or-later */ +use Contao\ArticleModel; use Contao\Automator; use Contao\CheckBox; use Contao\CheckBoxWizard; @@ -28,6 +29,7 @@ use Contao\ContentList; use Contao\ContentMarkdown; use Contao\ContentMedia; +use Contao\ContentModel; use Contao\ContentModule; use Contao\ContentSliderStart; use Contao\ContentSliderStop; @@ -40,16 +42,19 @@ use Contao\CoreBundle\Controller\BackendCsvImportController; use Contao\Crawl; use Contao\FileSelector; +use Contao\FilesModel; use Contao\FileTree; use Contao\Form; use Contao\FormCaptcha; use Contao\FormCheckBox; use Contao\FormExplanation; +use Contao\FormFieldModel; use Contao\FormFieldsetStart; use Contao\FormFieldsetStop; use Contao\FormFileUpload; use Contao\FormHidden; use Contao\FormHtml; +use Contao\FormModel; use Contao\FormPassword; use Contao\FormRadioButton; use Contao\FormRange; @@ -58,10 +63,15 @@ use Contao\FormTextArea; use Contao\FormTextField; use Contao\ImageSize; +use Contao\ImageSizeItemModel; +use Contao\ImageSizeModel; use Contao\InputUnit; use Contao\KeyValueWizard; +use Contao\LayoutModel; use Contao\ListWizard; use Contao\Maintenance; +use Contao\MemberGroupModel; +use Contao\MemberModel; use Contao\Messages; use Contao\MetaWizard; use Contao\ModuleArticleList; @@ -75,6 +85,7 @@ use Contao\ModuleLogin; use Contao\ModuleLogout; use Contao\ModuleMaintenance; +use Contao\ModuleModel; use Contao\ModuleNavigation; use Contao\ModulePassword; use Contao\ModulePersonalData; @@ -87,12 +98,14 @@ use Contao\ModuleSitemap; use Contao\ModuleTwoFactor; use Contao\ModuleWizard; +use Contao\OptInModel; use Contao\OptionWizard; use Contao\PageError401; use Contao\PageError403; use Contao\PageError404; use Contao\PageForward; use Contao\PageLogout; +use Contao\PageModel; use Contao\PageRedirect; use Contao\PageRegular; use Contao\PageRoot; @@ -107,6 +120,8 @@ use Contao\SelectMenu; use Contao\SerpPreview; use Contao\StringUtil; +use Contao\StyleModel; +use Contao\StyleSheetModel; use Contao\StyleSheets; use Contao\System; use Contao\TableWizard; @@ -114,9 +129,12 @@ use Contao\TextField; use Contao\TextStore; use Contao\Theme; +use Contao\ThemeModel; use Contao\TimePeriod; use Contao\TrblField; use Contao\Upload; +use Contao\UserGroupModel; +use Contao\UserModel; // Back end modules $GLOBALS['BE_MOD'] = array @@ -537,6 +555,27 @@ 'separator' => array() ); +// Models +$GLOBALS['TL_MODELS'] = array( + 'tl_article' => ArticleModel::class, + 'tl_content' => ContentModel::class, + 'tl_files' => FilesModel::class, + 'tl_form_field' => FormFieldModel::class, + 'tl_form' => FormModel::class, + 'tl_image_size_item' => ImageSizeItemModel::class, + 'tl_image_size' => ImageSizeModel::class, + 'tl_layout' => LayoutModel::class, + 'tl_member_group' => MemberGroupModel::class, + 'tl_member' => MemberModel::class, + 'tl_module' => ModuleModel::class, + 'tl_opt_in' => OptInModel::class, + 'tl_page' => PageModel::class, + 'tl_style' => StyleModel::class, + 'tl_style_sheet' => StyleSheetModel::class, + 'tl_theme' => ThemeModel::class, + 'tl_user_group' => UserGroupModel::class, + 'tl_user' => UserModel::class +); + // Other global arrays -$GLOBALS['TL_MODELS'] = array(); $GLOBALS['TL_PERMISSIONS'] = array(); diff --git a/faq-bundle/src/Resources/contao/config/config.php b/faq-bundle/src/Resources/contao/config/config.php index 65e49eb9a5e..38fdc466ad9 100644 --- a/faq-bundle/src/Resources/contao/config/config.php +++ b/faq-bundle/src/Resources/contao/config/config.php @@ -8,6 +8,8 @@ * @license LGPL-3.0-or-later */ +use Contao\FaqCategoryModel; +use Contao\FaqModel; use Contao\ModuleFaq; use Contao\ModuleFaqList; use Contao\ModuleFaqPage; @@ -39,3 +41,9 @@ // Add permissions $GLOBALS['TL_PERMISSIONS'][] = 'faqs'; $GLOBALS['TL_PERMISSIONS'][] = 'faqp'; + +// Models +$GLOBALS['TL_MODELS'] = array( + 'tl_faq_category' => FaqCategoryModel::class, + 'tl_faq' => FaqModel::class +); diff --git a/news-bundle/src/Resources/contao/config/config.php b/news-bundle/src/Resources/contao/config/config.php index 2a030a8a869..4c59978d419 100644 --- a/news-bundle/src/Resources/contao/config/config.php +++ b/news-bundle/src/Resources/contao/config/config.php @@ -14,6 +14,9 @@ use Contao\ModuleNewsMenu; use Contao\ModuleNewsReader; use Contao\News; +use Contao\NewsArchiveModel; +use Contao\NewsFeedModel; +use Contao\NewsModel; use Contao\TableWizard; // Back end modules @@ -52,3 +55,10 @@ $GLOBALS['TL_PERMISSIONS'][] = 'newp'; $GLOBALS['TL_PERMISSIONS'][] = 'newsfeeds'; $GLOBALS['TL_PERMISSIONS'][] = 'newsfeedp'; + +// Models +$GLOBALS['TL_MODELS'] = array( + 'tl_news_archive' => NewsArchiveModel::class, + 'tl_news_feed' => NewsFeedModel::class, + 'tl_news' => NewsModel::class +); diff --git a/newsletter-bundle/src/Resources/contao/config/config.php b/newsletter-bundle/src/Resources/contao/config/config.php index c390f2b9fb9..19351477223 100644 --- a/newsletter-bundle/src/Resources/contao/config/config.php +++ b/newsletter-bundle/src/Resources/contao/config/config.php @@ -13,6 +13,10 @@ use Contao\ModuleSubscribe; use Contao\ModuleUnsubscribe; use Contao\Newsletter; +use Contao\NewsletterChannelModel; +use Contao\NewsletterDenyListModel; +use Contao\NewsletterModel; +use Contao\NewsletterRecipientsModel; // Back end modules $GLOBALS['BE_MOD']['content']['newsletter'] = array @@ -44,3 +48,11 @@ // Cron jobs $GLOBALS['TL_CRON']['daily']['purgeNewsletterSubscriptions'] = array(Newsletter::class, 'purgeSubscriptions'); + +// Models +$GLOBALS['TL_MODELS'] = array( + 'tl_newsletter_channel' => NewsletterChannelModel::class, + 'tl_newsletter_deny_list' => NewsletterDenyListModel::class, + 'tl_newsletter' => NewsletterModel::class, + 'tl_newsletter_recipients' => NewsletterRecipientsModel::class +); From 3cb436fd2869e36670b26850ab4f5b6bd30214d5 Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Tue, 21 Jul 2020 15:43:35 +0200 Subject: [PATCH 2/3] Append to TL_MODELS instead of overwriting it --- calendar-bundle/src/Resources/contao/config/config.php | 8 +++----- comments-bundle/src/Resources/contao/config/config.php | 6 ++---- faq-bundle/src/Resources/contao/config/config.php | 6 ++---- news-bundle/src/Resources/contao/config/config.php | 8 +++----- .../src/Resources/contao/config/config.php | 10 ++++------ 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/calendar-bundle/src/Resources/contao/config/config.php b/calendar-bundle/src/Resources/contao/config/config.php index 9a100917a63..23c67035fda 100644 --- a/calendar-bundle/src/Resources/contao/config/config.php +++ b/calendar-bundle/src/Resources/contao/config/config.php @@ -57,8 +57,6 @@ $GLOBALS['TL_PERMISSIONS'][] = 'calendarfeedp'; // Models -$GLOBALS['TL_MODELS'] = array( - 'tl_calendar_events' => CalendarEventsModel::class, - 'tl_calendar_feed' => CalendarFeedModel::class, - 'tl_calendar' => CalendarModel::class -); +$GLOBALS['TL_MODELS']['tl_calendar_events'] = CalendarEventsModel::class; +$GLOBALS['TL_MODELS']['tl_calendar_feed'] = CalendarFeedModel::class; +$GLOBALS['TL_MODELS']['tl_calendar'] = CalendarModel::class; diff --git a/comments-bundle/src/Resources/contao/config/config.php b/comments-bundle/src/Resources/contao/config/config.php index 5e096fb7985..67a5a85ea95 100644 --- a/comments-bundle/src/Resources/contao/config/config.php +++ b/comments-bundle/src/Resources/contao/config/config.php @@ -31,7 +31,5 @@ $GLOBALS['TL_CRON']['daily']['purgeCommentSubscriptions'] = array(Comments::class, 'purgeSubscriptions'); // Models -$GLOBALS['TL_MODELS'] = array( - 'tl_comments' => CommentsModel::class, - 'tl_comments_notify' => CommentsNotifyModel::class -); +$GLOBALS['TL_MODELS']['tl_comments'] = CommentsModel::class; +$GLOBALS['TL_MODELS']['tl_comments_notify'] = CommentsNotifyModel::class; diff --git a/faq-bundle/src/Resources/contao/config/config.php b/faq-bundle/src/Resources/contao/config/config.php index 38fdc466ad9..fc2a1c27936 100644 --- a/faq-bundle/src/Resources/contao/config/config.php +++ b/faq-bundle/src/Resources/contao/config/config.php @@ -43,7 +43,5 @@ $GLOBALS['TL_PERMISSIONS'][] = 'faqp'; // Models -$GLOBALS['TL_MODELS'] = array( - 'tl_faq_category' => FaqCategoryModel::class, - 'tl_faq' => FaqModel::class -); +$GLOBALS['TL_MODELS']['tl_faq_category'] = FaqCategoryModel::class; +$GLOBALS['TL_MODELS']['tl_faq'] = FaqModel::class; diff --git a/news-bundle/src/Resources/contao/config/config.php b/news-bundle/src/Resources/contao/config/config.php index 4c59978d419..ad457f76943 100644 --- a/news-bundle/src/Resources/contao/config/config.php +++ b/news-bundle/src/Resources/contao/config/config.php @@ -57,8 +57,6 @@ $GLOBALS['TL_PERMISSIONS'][] = 'newsfeedp'; // Models -$GLOBALS['TL_MODELS'] = array( - 'tl_news_archive' => NewsArchiveModel::class, - 'tl_news_feed' => NewsFeedModel::class, - 'tl_news' => NewsModel::class -); +$GLOBALS['TL_MODELS']['tl_news_archive'] = NewsArchiveModel::class; +$GLOBALS['TL_MODELS']['tl_news_feed'] = NewsFeedModel::class; +$GLOBALS['TL_MODELS']['tl_news'] = NewsModel::class; diff --git a/newsletter-bundle/src/Resources/contao/config/config.php b/newsletter-bundle/src/Resources/contao/config/config.php index 19351477223..229ee46117b 100644 --- a/newsletter-bundle/src/Resources/contao/config/config.php +++ b/newsletter-bundle/src/Resources/contao/config/config.php @@ -50,9 +50,7 @@ $GLOBALS['TL_CRON']['daily']['purgeNewsletterSubscriptions'] = array(Newsletter::class, 'purgeSubscriptions'); // Models -$GLOBALS['TL_MODELS'] = array( - 'tl_newsletter_channel' => NewsletterChannelModel::class, - 'tl_newsletter_deny_list' => NewsletterDenyListModel::class, - 'tl_newsletter' => NewsletterModel::class, - 'tl_newsletter_recipients' => NewsletterRecipientsModel::class -); +$GLOBALS['TL_MODELS']['tl_newsletter_channel'] = NewsletterChannelModel::class; +$GLOBALS['TL_MODELS']['tl_newsletter_deny_list'] = NewsletterDenyListModel::class; +$GLOBALS['TL_MODELS']['tl_newsletter'] = NewsletterModel::class; +$GLOBALS['TL_MODELS']['tl_newsletter_recipients'] = NewsletterRecipientsModel::class; From c88a3552d05041bd68306a0d2c5e1bafea5b6fbc Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Tue, 21 Jul 2020 17:25:57 +0200 Subject: [PATCH 3/3] Trigger a deprecation for unregistered tables --- core-bundle/src/Resources/contao/library/Contao/Model.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-bundle/src/Resources/contao/library/Contao/Model.php b/core-bundle/src/Resources/contao/library/Contao/Model.php index 0b482fd35f9..afa08f7656c 100644 --- a/core-bundle/src/Resources/contao/library/Contao/Model.php +++ b/core-bundle/src/Resources/contao/library/Contao/Model.php @@ -1189,6 +1189,8 @@ public static function getClassFromTable($strTable) return static::$arrClassNames[$strTable]; } + trigger_deprecation('contao/core-bundle', '4.10', sprintf('Not registering table "%s" in $GLOBALS[\'TL_MODELS\'] has been deprecated and will no longer work in Contao 5.0.', $strTable)); + $arrChunks = explode('_', $strTable); if ($arrChunks[0] == 'tl')