From c84c51c82009a84b546e5b8acdd9314906ceb162 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sun, 28 Jun 2020 10:57:47 -0600 Subject: [PATCH] Improve error message when attempting to fork an unforkable component. Fixes #5142 and rainlab/forum-plugin#141 --- modules/cms/controllers/Index.php | 5 +++++ modules/cms/lang/en/lang.php | 1 + 2 files changed, 6 insertions(+) diff --git a/modules/cms/controllers/Index.php b/modules/cms/controllers/Index.php index 617e91bc3..094fdb7a9 100644 --- a/modules/cms/controllers/Index.php +++ b/modules/cms/controllers/Index.php @@ -403,6 +403,11 @@ class Index extends Controller $manager = ComponentManager::instance(); $componentObj = $manager->makeComponent($componentName); $partial = ComponentPartial::load($componentObj, 'default'); + + if (!$partial) { + throw new ApplicationException(Lang::get('cms::lang.component.no_default_partial')); + } + $content = $partial->getContent(); $content = str_replace('__SELF__', $alias, $content); diff --git a/modules/cms/lang/en/lang.php b/modules/cms/lang/en/lang.php index 66bad48cb..215bff893 100644 --- a/modules/cms/lang/en/lang.php +++ b/modules/cms/lang/en/lang.php @@ -249,6 +249,7 @@ return [ 'invalid_request' => 'The template cannot be saved because of invalid component data.', 'no_records' => 'No components found', 'not_found' => "The component ':name' is not found.", + 'no_default_partial' => "This component does not have a 'default' partial", 'method_not_found' => "The component ':name' does not contain a method ':method'.", 'soft_component' => 'Soft Component', 'soft_component_description' => 'This component is missing but optional.',