From 7fb8aab125e7f46f1bcb381be1be70477b6daf97 Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Sat, 30 Jan 2016 17:37:58 +0100
Subject: [PATCH] Store: setVarArray(): added flagOverwrite to allow
 overwriting during initialisation.

---
 qfq/store/Store.php | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/qfq/store/Store.php b/qfq/store/Store.php
index 2aabd0340..60e512a68 100644
--- a/qfq/store/Store.php
+++ b/qfq/store/Store.php
@@ -160,7 +160,7 @@ class Store {
         } catch (\Exception $e) {
             throw new qfq\UserException ("Error read file " . QFQ_INI . ": " . $e->getMessage(), ERROR_READ_FILE);
         }
-        self::setVarArray($config, STORE_SYSTEM);
+        self::setVarArray($config, STORE_SYSTEM,true);
     }
 
     /**
@@ -168,9 +168,9 @@ class Store {
      * @param $store
      * @throws CodeException
      */
-    public function setVarArray(array $dataArray, $store) {
+    public function setVarArray(array $dataArray, $store, $flagOverwrite = false) {
 
-        if (isset(self::$raw[$store]) && count(self::$raw[$store]) > 0) {
+        if ($flagOverwrite && isset(self::$raw[$store]) && count(self::$raw[$store]) > 0) {
             throw new CodeException("Raw values already been copied to store '$store'. Do this only one time.", ERROR_VALUE_ALREADY_CODPIED);
         }
 
@@ -194,7 +194,7 @@ class Store {
         if (isset($GLOBALS["TSFE"]->fe_user->user["usergroup"]))
             $arr[TYPO3_FE_USER_GROUP] = $GLOBALS["TSFE"]->fe_user->user["usergroup"];
 
-        self::setVarArray($arr, STORE_TYPO3);
+        self::setVarArray($arr, STORE_TYPO3, true);
     }
 
     /*
@@ -215,7 +215,7 @@ class Store {
         if (isset($_POST[CLIENT_SIP]))
             $arr[CLIENT_POST_SIP] = $_POST[CLIENT_SIP];
 
-        self::setVarArray($arr, STORE_CLIENT);
+        self::setVarArray($arr, STORE_CLIENT, true);
     }
 
     /**
@@ -235,7 +235,7 @@ class Store {
             $param[SIP_URLPARAM] = self::$sip->getQueryStringFromSip($s);
 
 //            self::setVarArray(KeyValueStringParser::parse($param, "=", "&"), STORE_SIP);
-            self::setVarArray($param, STORE_SIP);
+            self::setVarArray($param, STORE_SIP, true);
         }
     }
 
@@ -330,15 +330,17 @@ class Store {
 
         $tmpParam = [SIP_RECORD_ID => $recordId, SIP_FORM => $formName];
 
-        // Store in SIP Store (cause it's empty until now).
-        self::setVarArray($tmpParam, STORE_SIP);
-
         // Construct fake urlparam
         $tmpUrlparam = OnArray::toString($tmpParam);
 
         // Create a fake SIP which has never been passed by URL - further processing might expect this to exist.
         $sip = self::getSip()->queryStringToSip($tmpUrlparam, RETURN_SIP);
         self::setVar(CLIENT_SIP, $sip, STORE_CLIENT);
+
+        // Store in SIP Store (cause it's empty until now).
+        $tmpParam[SIP_SIP] = $sip;
+        self::setVarArray($tmpParam, STORE_SIP);
+
     }
 
     /**
-- 
GitLab