From cc0928e1421e2608347c5167ae5703b158f503ad Mon Sep 17 00:00:00 2001 From: dGrammatiko Date: Sun, 16 Aug 2020 16:59:19 +0200 Subject: [PATCH 1/4] Handle templateInherits in all Apps correctly --- libraries/src/Application/WebApplication.php | 7 ++++--- libraries/src/Error/Renderer/HtmlRenderer.php | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/libraries/src/Application/WebApplication.php b/libraries/src/Application/WebApplication.php index adbefcc9b55bb..ecc565b5d59f4 100644 --- a/libraries/src/Application/WebApplication.php +++ b/libraries/src/Application/WebApplication.php @@ -180,9 +180,10 @@ protected function render() { // Setup the document options. $options = array( - 'template' => $this->get('theme'), - 'file' => $this->get('themeFile', 'index.php'), - 'params' => $this->get('themeParams'), + 'template' => $this->get('theme'), + 'file' => $this->get('themeFile', 'index.php'), + 'params' => $this->get('themeParams'), + 'templateInherits' => $this->get('themeInherits'), ); if ($this->get('themes.base')) diff --git a/libraries/src/Error/Renderer/HtmlRenderer.php b/libraries/src/Error/Renderer/HtmlRenderer.php index f884c843f2773..2a99c65099825 100644 --- a/libraries/src/Error/Renderer/HtmlRenderer.php +++ b/libraries/src/Error/Renderer/HtmlRenderer.php @@ -44,14 +44,20 @@ public function render(\Throwable $error): string $app = Factory::getApplication(); // Get the current template from the application - $template = $app->getTemplate(); + $template = $app->getTemplate(true); // Push the error object into the document $this->getDocument()->setError($error); // Add registry file for the template asset - $this->getDocument()->getWebAssetManager()->getRegistry() - ->addTemplateRegistryFile($template, $app->getClientId()); + $wa = $this->getDocument()->getWebAssetManager()->getRegistry(); + + $wa->addTemplateRegistryFile($template->template, $app->getClientId()); + + if (!empty($template->parent)) + { + $wa->addTemplateRegistryFile($template->parent, $app->getClientId()); + } if (ob_get_contents()) { @@ -63,10 +69,11 @@ public function render(\Throwable $error): string return $this->getDocument()->render( false, [ - 'template' => $template, - 'directory' => JPATH_THEMES, - 'debug' => JDEBUG, - 'csp_nonce' => $app->get('csp_nonce'), + 'template' => $template->template, + 'directory' => JPATH_THEMES, + 'debug' => JDEBUG, + 'csp_nonce' => $app->get('csp_nonce'), + 'templateInherits' => $template->parent ] ); } From 15b510e71fa4c8fb88e113e36592f931fcbe7774 Mon Sep 17 00:00:00 2001 From: dGrammatiko Date: Mon, 17 Aug 2020 12:21:34 +0200 Subject: [PATCH 2/4] API getTemplate() should retrun object Same as the installation Application: https://github.com/joomla/joomla-cms/blob/32260311c0b6cdcc4b4686649ede1e958b9120ce/installation/src/Application/InstallationApplication.php#L401-L415 --- libraries/src/Application/ApiApplication.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/src/Application/ApiApplication.php b/libraries/src/Application/ApiApplication.php index 7edad11c8424f..aaab8c28a43cb 100644 --- a/libraries/src/Application/ApiApplication.php +++ b/libraries/src/Application/ApiApplication.php @@ -186,6 +186,17 @@ protected function respond($options = array()) public function getTemplate($params = false) { // The API application should not need to use a template + if ($params) + { + $template = new \stdClass; + $template->template = 'system'; + $template->params = new Registry; + $template->inheritable = 0; + $template->parent = null; + + return $template; + } + return 'system'; } From 7d37f576d1a021dfc70aa410ddea187b72939e39 Mon Sep 17 00:00:00 2001 From: dGrammatiko Date: Tue, 18 Aug 2020 13:30:39 +0200 Subject: [PATCH 3/4] Update ApiApplication.php --- libraries/src/Application/ApiApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Application/ApiApplication.php b/libraries/src/Application/ApiApplication.php index aaab8c28a43cb..55b8971de331e 100644 --- a/libraries/src/Application/ApiApplication.php +++ b/libraries/src/Application/ApiApplication.php @@ -192,7 +192,7 @@ public function getTemplate($params = false) $template->template = 'system'; $template->params = new Registry; $template->inheritable = 0; - $template->parent = null; + $template->parent = ''; return $template; } From 0cc55409677ed339cd400106ce0d7373c45ea908 Mon Sep 17 00:00:00 2001 From: dGrammatiko Date: Tue, 18 Aug 2020 13:32:11 +0200 Subject: [PATCH 4/4] Update InstallationApplication.php --- installation/src/Application/InstallationApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation/src/Application/InstallationApplication.php b/installation/src/Application/InstallationApplication.php index bc50f4461b500..611cd4f0ee11d 100644 --- a/installation/src/Application/InstallationApplication.php +++ b/installation/src/Application/InstallationApplication.php @@ -406,7 +406,7 @@ public function getTemplate($params = false) $template->template = 'template'; $template->params = new Registry; $template->inheritable = 0; - $template->parent = null; + $template->parent = ''; return $template; }