From 6540bec41493fc6c2055b13ea134580e4ce11c26 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Wed, 13 Jun 2018 15:41:13 +0300
Subject: [PATCH] Make sure to init theme just once. (#1202)

---
 module/VuFindTheme/src/VuFindTheme/Initializer.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/module/VuFindTheme/src/VuFindTheme/Initializer.php b/module/VuFindTheme/src/VuFindTheme/Initializer.php
index bef5f0852f9..bbfba623472 100644
--- a/module/VuFindTheme/src/VuFindTheme/Initializer.php
+++ b/module/VuFindTheme/src/VuFindTheme/Initializer.php
@@ -86,6 +86,13 @@ class Initializer
      */
     protected $cookieManager;
 
+    /**
+     * A static flag used to determine if the theme has been initialized
+     *
+     * @var bool
+     */
+    protected static $themeInitialized = false;
+
     /**
      * Constructor
      *
@@ -180,6 +187,12 @@ class Initializer
      */
     public function init()
     {
+        // Make sure to initialize the theme just once
+        if (self::$themeInitialized) {
+            return;
+        }
+        self::$themeInitialized = true;
+
         // Determine the current theme:
         $currentTheme = $this->pickTheme($this->event->getRequest());
 
-- 
GitLab