From b617517384595b71367baa12da4c8baa2bf3c1a5 Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Fri, 13 May 2016 15:54:07 +0200
Subject: [PATCH] Report.php: set default value for $t3data["uid"]. $bodyText
 now given to process() instead of the constructor - makes testing easier.
 QuickFormQuery.php: applied change of 'bodytext' from Report.php.

---
 extension/qfq/qfq/QuickFormQuery.php | 2 +-
 extension/qfq/qfq/report/Report.php  | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php
index 754f5de64..8b6fa21ff 100644
--- a/extension/qfq/qfq/QuickFormQuery.php
+++ b/extension/qfq/qfq/QuickFormQuery.php
@@ -535,7 +535,7 @@ class QuickFormQuery {
     private function doReport() {
         $report = new Report($this->t3data, $this->store->getVar(SYSTEM_SESSION_NAME, STORE_SYSTEM), $this->eval, $this->phpUnit);
 
-        $html = $report->process();
+        $html = $report->process($this->t3data['bodytext']);
 
         return $html;
 
diff --git a/extension/qfq/qfq/report/Report.php b/extension/qfq/qfq/report/Report.php
index 86261f6de..42928b4a6 100644
--- a/extension/qfq/qfq/report/Report.php
+++ b/extension/qfq/qfq/report/Report.php
@@ -94,6 +94,8 @@ class Report {
 
         $this->phpUnit = $phpUnit;
 
+        Support::setIfNotSet($t3data, "uid", 0);
+
         $this->t3data = $t3data;
         $this->sip = new Sip($sessionName, $phpUnit);
         $this->store = Store::getInstance();
@@ -119,7 +121,7 @@ class Report {
 
         // Set static values, which won't change during this run.
         $this->fr_error["pid"] = isset($this->variables->resultArray['global.']['page_id']) ? $this->variables->resultArray['global.']['page_id'] : 0;
-        $this->fr_error["uid"] = $t3data["uid"];
+        $this->fr_error["uid"] = $t3data['uid'];
         $this->fr_error["debug_level"] = 0;
 
         // Sanitize function for POST and GET Parameters.
@@ -138,12 +140,12 @@ class Report {
      *
      * @return string
      */
-    public function process() {
+    public function process($bodyText) {
 
         $this->log->set_fr_error($this->fr_error);
 
         // Iteration over Bodytext
-        $ttLineArray = explode("\n", $this->t3data['bodytext']);
+        $ttLineArray = explode("\n", $bodyText);
 
         foreach ($ttLineArray as $index => $line) {
             // Fill $frArray, $indexArray, $resultArray
-- 
GitLab