From 83316242fc419454a578ed5ced214413d2638f11 Mon Sep 17 00:00:00 2001
From: enured <enis.nuredini@uzh.ch>
Date: Mon, 7 Mar 2022 09:40:41 +0100
Subject: [PATCH] B11325 SQL CALL is handled seperate. All statements will
 execute. If only a SELECT statement is used in PROCEDURE then the output will
 shown, otherwise not.

---
 extension/Classes/Core/Database/Database.php | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/extension/Classes/Core/Database/Database.php b/extension/Classes/Core/Database/Database.php
index f78282980..30eced3a0 100644
--- a/extension/Classes/Core/Database/Database.php
+++ b/extension/Classes/Core/Database/Database.php
@@ -441,7 +441,6 @@ class Database {
             case 'SHOW':
             case 'DESCRIBE':
             case 'EXPLAIN':
-            case 'CALL':
                 if (false === ($result = $this->mysqli_stmt->get_result())) {
                     throw new \DbException(
                         json_encode([ERROR_MESSAGE_TO_USER => 'Error DB execute', ERROR_MESSAGE_TO_DEVELOPER => '[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $specificMessage]),
@@ -454,6 +453,20 @@ class Database {
                 $count = $stat[DB_NUM_ROWS];
                 $msg = 'Read rows: ' . $stat[DB_NUM_ROWS];
                 break;
+            case 'CALL':
+                $result = $this->mysqli_stmt->get_result();
+                $queryType = QUERY_TYPE_SELECT;
+                If($result === false){
+                    $stat[DB_NUM_ROWS] = 0;
+                    $count = $stat[DB_NUM_ROWS];
+                    $msg = 'Read rows: ' . $stat[DB_NUM_ROWS] . '(No SELECT statement)';
+                }else{
+                    $this->mysqli_result = $result;
+                    $stat[DB_NUM_ROWS] = $this->mysqli_result->num_rows;
+                    $count = $stat[DB_NUM_ROWS];
+                    $msg = 'Read rows: ' . $stat[DB_NUM_ROWS];
+                }
+                break;
             case 'REPLACE':
             case 'INSERT':
                 $queryType = QUERY_TYPE_INSERT;
-- 
GitLab