From 66d5d0d86d0d5b7992ab560ae4a6393d0e06ff51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaime=20Pe=CC=81rez=20Crespo?= <jaime.perez@uninett.no>
Date: Wed, 5 Jul 2017 12:23:52 +0200
Subject: [PATCH] Make sure the template cache can be used if
 "template.auto_reload" is set to true.

---
 config-templates/config.php       | 15 ++++++++++-----
 lib/SimpleSAML/XHTML/Template.php |  6 +-----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/config-templates/config.php b/config-templates/config.php
index c3e8bb930..f25f30b1e 100644
--- a/config-templates/config.php
+++ b/config-templates/config.php
@@ -725,14 +725,19 @@ $config = array(
      *
      * By default, twig templates are not cached. To turn on template caching:
      * Set 'template.cache' to an absolute path pointing to a directory that
-     * SimpleSAMLphp has read and write permissions to. Then, set
-     * 'template.auto_reload' to false.
-     *
-     * When upgrading or changing themes, delete the contents of the cache.
+     * SimpleSAMLphp has read and write permissions to.
      */
-    'template.auto_reload' => true,
     //'template.cache' => '',
 
+    /*
+     * Set the 'template.auto_reload' to true if you would like SimpleSAMLphp to
+     * recompile the templates (when using the template cache) if the templates
+     * change. If you don't want to check the source templates for every request,
+     * set it to false.
+     */
+    'template.auto_reload' => false,
+
+
 
     /*********************
      | DISCOVERY SERVICE |
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index ab2ebff03..8ee2f806f 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -162,11 +162,7 @@ class SimpleSAML_XHTML_Template
     private function setupTwig()
     {
         $auto_reload = $this->configuration->getBoolean('template.auto_reload', true);
-        $cache = false;
-        if (!$auto_reload) {
-            // Cache only used if auto_reload = false
-            $cache = $this->configuration->getString('template.cache', $this->configuration->resolvePath('cache'));
-        }
+        $cache = $this->configuration->getString('template.cache', false);
         // set up template paths
         $loader = $this->setupTwigTemplatepaths();
         // abort if twig template does not exist
-- 
GitLab