From 72b769aa63e42758891b055da13e6a7e05658ccf Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 21 Feb 2023 09:39:14 -0700 Subject: [PATCH 1/3] fix for rendering specific templates fixes #3698 --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Twig/Twig.php | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d2f34d75..436973556d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.7.40 +## 02/dd/2023 + +1. [](#bugfix) + * Fix for overzealous modular page template rendering fix in 1.7.39 causing Feed plugin to break [#3689](https://github.com/getgrav/grav/issues/3689) + # v1.7.39.2 ## 02/20/2023 diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 1d2beb9532..e1709d104d 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -493,13 +493,19 @@ public function prependPath($template_path, $namespace = '__main__') /** * Simple helper method to get the twig template if it has already been set, else return * the one being passed in + * NOTE: Modular pages that are injected should not use this pre-set template as it's usually set at the page level * - * @param string $template the template name + * @param PageInterface $page the template name * @return string the template name */ - public function template($template) + public function template(PageInterface $page, string $extension): string { - return $this->template ?? $template; + $template = $page->template() . $extension; + if ($page->isModule()) { + return $template; + } else { + return $this->template ?? $template; + } } /** @@ -513,7 +519,8 @@ public function getPageTwigTemplate($page, &$format = null) $default = $page->isModule() ? 'modular/default' : 'default'; $extension = $format ?: $page->templateFormat(); $twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT; - $template_file = $template . $twig_extension; +// $template_file = $template . $twig_extension; + $template_file = $this->template($page, $twig_extension); // TODO: no longer needed in Twig 3. /** @var ExistsLoaderInterface $loader */ From b2f27fbdf298826ff378c5ec1dd7e592056ec071 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 21 Feb 2023 12:55:50 -0700 Subject: [PATCH 2/3] cleaner fix for template bug --- system/src/Grav/Common/Twig/Twig.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index e1709d104d..a52bb6de8f 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -495,17 +495,17 @@ public function prependPath($template_path, $namespace = '__main__') * the one being passed in * NOTE: Modular pages that are injected should not use this pre-set template as it's usually set at the page level * - * @param PageInterface $page the template name + * @param string $template the template name * @return string the template name */ - public function template(PageInterface $page, string $extension): string + public function template(string $template): string { - $template = $page->template() . $extension; - if ($page->isModule()) { - return $template; - } else { - return $this->template ?? $template; + if (isset($this->template)) { + $template = $this->template; + unset($this->template); } + + return $template; } /** @@ -519,8 +519,7 @@ public function getPageTwigTemplate($page, &$format = null) $default = $page->isModule() ? 'modular/default' : 'default'; $extension = $format ?: $page->templateFormat(); $twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT; -// $template_file = $template . $twig_extension; - $template_file = $this->template($page, $twig_extension); + $template_file = $this->template($template . $twig_extension); // TODO: no longer needed in Twig 3. /** @var ExistsLoaderInterface $loader */ From 88350d90904d60cb7ae0f2cfd4f53339fd982337 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 21 Feb 2023 15:12:24 -0700 Subject: [PATCH 3/3] prepare for release --- CHANGELOG.md | 4 ++-- system/defines.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 436973556d..2932c3d6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# v1.7.40 -## 02/dd/2023 +# v1.7.39.3 +## 02/21/2023 1. [](#bugfix) * Fix for overzealous modular page template rendering fix in 1.7.39 causing Feed plugin to break [#3689](https://github.com/getgrav/grav/issues/3689) diff --git a/system/defines.php b/system/defines.php index e26f1c9957..b343f05263 100644 --- a/system/defines.php +++ b/system/defines.php @@ -9,7 +9,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.7.39.2'); +define('GRAV_VERSION', '1.7.39.3'); define('GRAV_SCHEMA', '1.7.0_2020-11-20_1'); define('GRAV_TESTING', false);