From 8e0549362d746d53d7731394fd4793dcae6b7014 Mon Sep 17 00:00:00 2001
From: kputyr <krzysztof.putyra@math.uzh.ch>
Date: Fri, 17 Nov 2023 13:11:28 +0100
Subject: [PATCH] Removed Enis changes to Database and fixed those in Report

---
 extension/Classes/Core/Database/Database.php | 20 +++++++++++---------
 extension/Classes/Core/Report/Report.php     |  3 ++-
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/extension/Classes/Core/Database/Database.php b/extension/Classes/Core/Database/Database.php
index d22f9dcb3..59a0ed105 100644
--- a/extension/Classes/Core/Database/Database.php
+++ b/extension/Classes/Core/Database/Database.php
@@ -402,15 +402,17 @@ class Database {
 
         // Author: Enis Nuredini
         // Get method from query and remove it from the sql variable to get a valid mysqli_stmt. Store given method in system store
-        $needle = 'AS _encrypt=';
-        if (mb_strpos($sql, $needle)) {
-            $preparedSql = explode('AS _encrypt=', $sql);
-            $sql = $preparedSql[0] . ' AS _encrypt';
-            $encryptionMethod = $preparedSql[1];
-            $this->store::setVar(ENCRYPTION_CIPHER_METHOD_COLUMN_NAME, $encryptionMethod, STORE_SYSTEM);
-        } else if ($this->store::getVar(ENCRYPTION_CIPHER_METHOD_COLUMN_NAME, STORE_SYSTEM, SANITIZE_ALLOW_ALL) !== null) {
-            $this->store::unsetVar(ENCRYPTION_CIPHER_METHOD_COLUMN_NAME, STORE_SYSTEM);
-        }
+        // Krzysztof Putyra: commented out, because it breaks SQL statements.
+        // If this feature is needed, a smart parser must be used
+//        $needle = 'AS _encrypt=';
+//        if (mb_strpos($sql, $needle)) {
+//            $preparedSql = explode('AS _encrypt=', $sql);
+//            $sql = $preparedSql[0] . ' AS _encrypt';
+//            $encryptionMethod = $preparedSql[1];
+//            $this->store::setVar(ENCRYPTION_CIPHER_METHOD_COLUMN_NAME, $encryptionMethod, STORE_SYSTEM);
+//        } else if ($this->store::getVar(ENCRYPTION_CIPHER_METHOD_COLUMN_NAME, STORE_SYSTEM, SANITIZE_ALLOW_ALL) !== null) {
+//            $this->store::unsetVar(ENCRYPTION_CIPHER_METHOD_COLUMN_NAME, STORE_SYSTEM);
+//        }
         // End from author
 
         if (false === ($this->mysqli_stmt = $this->mysqli->prepare($sql))) {
diff --git a/extension/Classes/Core/Report/Report.php b/extension/Classes/Core/Report/Report.php
index ce3b53ea6..387711654 100644
--- a/extension/Classes/Core/Report/Report.php
+++ b/extension/Classes/Core/Report/Report.php
@@ -853,10 +853,11 @@ class Report {
 
             // Author: Enis Nuredini
             // Split and get given encryption method from column name
+            // Fixed temporarily by Krzysztof Putyra
             $encryptionMethod = null;
             $key = $arr[0];
             $keyArray = explode('=', $key, 2);
-            if (isset($keyArray[1]) && $keyArray[1] !== '' && $keyArray[0] === COLUMN_ENCRYPT) {
+            if (isset($keyArray[1]) && $keyArray[1] !== '' && $keyArray[0] === TOKEN_COLUMN_CTRL . COLUMN_ENCRYPT) {
                 $encryptionMethod = $keyArray[1];
                 $arr[0] = $keyArray[0];
             }
-- 
GitLab