diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 30d7ddb85678e8510b4631b2c79004080b5bed35..d7f6e2e264626da937b1d0bb8c747cfd6c51b266 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -379,6 +379,7 @@ const TOKEN_VALID_LIST = 'sql|head|althead|tail|rbeg|rend|renr|rsep|fbeg|fend|fs // SQL logging Modes const SQL_LOG_MODE_ALL = 'all'; const SQL_LOG_MODE_MODIFY = 'modify'; +const SQL_LOG_MODE_ERROR = 'error'; // write log entry, independent of global setting (e.g. broken Query) // api/save.php, api/delete.php, api/load.php const API_DELETE_PHP = 'delete.php'; diff --git a/extension/qfq/qfq/Database.php b/extension/qfq/qfq/Database.php index 6294700aefc07b498b668142a6513f83c897d58b..25c88e3a192234632736d20e949d7a2ead3d403d 100644 --- a/extension/qfq/qfq/Database.php +++ b/extension/qfq/qfq/Database.php @@ -238,7 +238,6 @@ class Database { $sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;; $result = 0; $stat = array(); - $debugSql = ''; $this->store->setVar(SYSTEM_SQL_FINAL, $sql, STORE_SYSTEM); $this->store->setVar(SYSTEM_SQL_PARAM_ARRAY, $parameterArray, STORE_SYSTEM); @@ -246,26 +245,21 @@ class Database { // Logfile $this->dbLog($sqlLogMode, $sql, $parameterArray); - // If BE User is logged in: report the broken SQL as well. - - //TODO: im Fall von delete.php, save.php, kann hier der BE_USER nicht abgefragt werden (laeuft nicht durch T3) - Loesung finden. - - if (true) { - $debugSql = '[' . $sql . ']'; - } - if (false === ($this->mysqli_stmt = $this->mysqli->prepare($sql))) { - throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error . $debugSql, ERROR_DB_PREPARE); + $this->dbLog(SQL_LOG_MODE_ERROR, $sql, $parameterArray); + throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error, ERROR_DB_PREPARE); } if (count($parameterArray) > 0) { if (false === $this->prepareBindParam($parameterArray)) { - throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $debugSql, ERROR_DB_BIND); + $this->dbLog(SQL_LOG_MODE_ERROR, $sql, $parameterArray); + throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_BIND); } } if (false === $this->mysqli_stmt->execute()) { - throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $debugSql, ERROR_DB_EXECUTE); + $this->dbLog(SQL_LOG_MODE_ERROR, $sql, $parameterArray); + throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_EXECUTE); } $msg = ''; @@ -351,6 +345,8 @@ class Database { */ private function dbLog($mode = SQL_LOG_MODE_ALL, $sql = '', $parameterArray = array()) { + $status = ''; + $sqlLogMode = $this->store->getVar(SYSTEM_SQL_LOG_MODE, STORE_SYSTEM); switch ($mode) { @@ -363,6 +359,9 @@ class Database { case SQL_LOG_MODE_MODIFY: break; + case SQL_LOG_MODE_ERROR: + break; + default: throw new UserFormException("Unknown SQL_LOG_MODE: $mode", ERROR_UNKNOWN_SQL_LOG_MODE); } @@ -382,7 +381,10 @@ class Database { } if ($sql !== '') { - $msg .= '[' . $sql . ']'; + if ($mode == SQL_LOG_MODE_ERROR) { + $status = 'FAILED: '; + } + $msg .= '[' . $status . $sql . ']'; } Logger::logMessage($msg, $this->sqlLog); diff --git a/extension/qfq/qfq/exceptions/AbstractException.php b/extension/qfq/qfq/exceptions/AbstractException.php index 861273bbafccaff373ee94f0b05eda66ec1732ab..b48a72ed35379c69404698942b27e107a5c6e782 100644 --- a/extension/qfq/qfq/exceptions/AbstractException.php +++ b/extension/qfq/qfq/exceptions/AbstractException.php @@ -39,7 +39,7 @@ class AbstractException extends \Exception { $this->messageArray['Line'] = $this->getLine(); $this->messageArray['Message'] = $this->getMessage(); $this->messageArray['Code'] = $this->getCode(); - + $this->messageArray['Timestamp'] = date('Y.m.d H:i:s O'); $this->messageArray['Stacktrace'] = '<pre>' . $this->getTraceAsString() . '</pre>'; if ($store !== null) { $this->messageArray['Page Id'] = $store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);