From 4b757f157c3e50da82940493df8175f3b4f8a4f4 Mon Sep 17 00:00:00 2001 From: JoeforJoomla Boy Date: Fri, 27 Jan 2017 11:16:59 +0100 Subject: [PATCH 1/5] Update site.php --- libraries/cms/application/site.php | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/libraries/cms/application/site.php b/libraries/cms/application/site.php index daf33a2ce734c..1a72f32d62273 100644 --- a/libraries/cms/application/site.php +++ b/libraries/cms/application/site.php @@ -466,13 +466,7 @@ public function getTemplate($params = false) $tag = ''; } - $cacheId = 'templates0' . $tag; - - if ($cache->contains($cacheId)) - { - $templates = $cache->get($cacheId); - } - else + if (!$templates = $cache->get('templates0' . $tag)) { // Load styles $db = JFactory::getDbo(); @@ -488,23 +482,18 @@ public function getTemplate($params = false) foreach ($templates as &$template) { + $registry = new Registry; + $registry->loadString($template->params); + $template->params = $registry; + // Create home element - if ($template->home == 1 && !isset($template_home) || $this->_language_filter && $template->home == $tag) + if ($template->home == 1 && !isset($templates[0]) || $this->_language_filter && $template->home == $tag) { - $template_home = clone $template; + $templates[0] = clone $template; } - - $template->params = new Registry($template->params); - } - - // Add home element, after loop to avoid double execution - if (isset($template_home)) - { - $template_home->params = new Registry($template_home->params); - $templates[0] = $template_home; } - $cache->store($templates, $cacheId); + $cache->store($templates, 'templates0' . $tag); } if (isset($templates[$id])) From fb66473ef1298d0f9b913e6644ddb8637ff01a1d Mon Sep 17 00:00:00 2001 From: JoeforJoomla Boy Date: Fri, 27 Jan 2017 22:38:20 +0100 Subject: [PATCH 2/5] Update site.php --- libraries/cms/application/site.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/cms/application/site.php b/libraries/cms/application/site.php index 1a72f32d62273..d450140afa3ae 100644 --- a/libraries/cms/application/site.php +++ b/libraries/cms/application/site.php @@ -496,6 +496,9 @@ public function getTemplate($params = false) $cache->store($templates, 'templates0' . $tag); } + // Unset the $template reference to the last $templates[n] item cycled in the foreach above to avoid to edit the $templates array in the following assignment + unset($template); + if (isset($templates[$id])) { $template = $templates[$id]; From 33ffdfa08de4ae106b8e771408406e96f135d9ff Mon Sep 17 00:00:00 2001 From: JoeforJoomla Boy Date: Fri, 27 Jan 2017 22:49:06 +0100 Subject: [PATCH 3/5] Update site.php --- libraries/cms/application/site.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/libraries/cms/application/site.php b/libraries/cms/application/site.php index d450140afa3ae..daf33a2ce734c 100644 --- a/libraries/cms/application/site.php +++ b/libraries/cms/application/site.php @@ -466,7 +466,13 @@ public function getTemplate($params = false) $tag = ''; } - if (!$templates = $cache->get('templates0' . $tag)) + $cacheId = 'templates0' . $tag; + + if ($cache->contains($cacheId)) + { + $templates = $cache->get($cacheId); + } + else { // Load styles $db = JFactory::getDbo(); @@ -482,23 +488,25 @@ public function getTemplate($params = false) foreach ($templates as &$template) { - $registry = new Registry; - $registry->loadString($template->params); - $template->params = $registry; - // Create home element - if ($template->home == 1 && !isset($templates[0]) || $this->_language_filter && $template->home == $tag) + if ($template->home == 1 && !isset($template_home) || $this->_language_filter && $template->home == $tag) { - $templates[0] = clone $template; + $template_home = clone $template; } + + $template->params = new Registry($template->params); + } + + // Add home element, after loop to avoid double execution + if (isset($template_home)) + { + $template_home->params = new Registry($template_home->params); + $templates[0] = $template_home; } - $cache->store($templates, 'templates0' . $tag); + $cache->store($templates, $cacheId); } - // Unset the $template reference to the last $templates[n] item cycled in the foreach above to avoid to edit the $templates array in the following assignment - unset($template); - if (isset($templates[$id])) { $template = $templates[$id]; From 64701efaf3ac544081759e3987020350d52029e8 Mon Sep 17 00:00:00 2001 From: JoeforJoomla Boy Date: Fri, 27 Jan 2017 22:51:52 +0100 Subject: [PATCH 4/5] Update site.php --- libraries/cms/application/site.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/cms/application/site.php b/libraries/cms/application/site.php index daf33a2ce734c..d5e66bf07066a 100644 --- a/libraries/cms/application/site.php +++ b/libraries/cms/application/site.php @@ -507,6 +507,8 @@ public function getTemplate($params = false) $cache->store($templates, $cacheId); } + // Unset the $template reference to the last $templates[n] item cycled in the foreach above to avoid to edit the $templates array in the following assignment + unset($template); if (isset($templates[$id])) { $template = $templates[$id]; From 796a05781a6c11b125351993d403917165edb65d Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sat, 28 Jan 2017 09:41:27 -0600 Subject: [PATCH 5/5] Move unset into the else condition --- libraries/cms/application/site.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/cms/application/site.php b/libraries/cms/application/site.php index d5e66bf07066a..ff95aa359f115 100644 --- a/libraries/cms/application/site.php +++ b/libraries/cms/application/site.php @@ -497,6 +497,9 @@ public function getTemplate($params = false) $template->params = new Registry($template->params); } + // Unset the $template reference to the last $templates[n] item cycled in the foreach above to avoid editing it later + unset($template); + // Add home element, after loop to avoid double execution if (isset($template_home)) { @@ -507,8 +510,6 @@ public function getTemplate($params = false) $cache->store($templates, $cacheId); } - // Unset the $template reference to the last $templates[n] item cycled in the foreach above to avoid to edit the $templates array in the following assignment - unset($template); if (isset($templates[$id])) { $template = $templates[$id];