Commit 4b0d1413 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3766 / SQL_LOG per tt_content record einstellbar machen

Add `sqlLog` and `sqlLogMode` to QFQ tt-content records.
Add mode 'error' and `none` to sqlLogMode.
Manual.rst: Added explanations for SQL_LOG, SQL_LOG_MODE, and tt-content pendants sqlLog, sqlLogMode. Update config.qfq.ini to latest attributes.
Database.php: rename $mode to $currentQueryMode to make it more descriptive. Recode dbLog().
Logger.php: do nothing if there is no file defined.
Report.php: new function checkUpdateLog().
Config.php: Set defaults for config.qfq.ini SQL_LOG and SQL_LOG_MODE
Store.php: Fix problem that an empty SQL_LOG will be prependad with SYSTEM_PATH_EXT.
parent de0ec670
...@@ -67,7 +67,7 @@ Preparation steps for Ubuntu 16.04:: ...@@ -67,7 +67,7 @@ Preparation steps for Ubuntu 16.04::
sudo apt install php7.0-intl sudo apt install php7.0-intl
sudo apt install pdftk libxrender1 file # for file upload, PDF and 'HTML to PDF' (wkhtmltopdf) sudo apt install pdftk libxrender1 file # for file upload, PDF and 'HTML to PDF' (wkhtmltopdf)
.. _wkhtmltopdf: .. _wkhtml:
wkhtmltopdf wkhtmltopdf
^^^^^^^^^^^ ^^^^^^^^^^^
...@@ -235,11 +235,11 @@ config.qfq.ini ...@@ -235,11 +235,11 @@ config.qfq.ini
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SQL_LOG | SQL_LOG=sql.log | Filename to log SQL commands: relative to <ext_dir> or absolute. | | SQL_LOG | SQL_LOG=sql.log | Filename to log SQL commands: relative to <ext_dir> or absolute. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SQL_LOG_MODE | SQL_LOG_MODE=modify | *all*: every statement will be logged - this is a lot | | SQL_LOG_MODE | SQL_LOG_MODE=modify | *all*: every statement will be logged - this might a lot. |
| | | *modify*: log only statements who change data | | | | *modify*: log only statements who change data. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| SHOW_DEBUG_INFO | SHOW_DEBUG_INFO=auto | Possible values: yes|no|auto|download. For 'auto': If a BE User is logged | | SHOW_DEBUG_INFO | SHOW_DEBUG_INFO=auto | FE - Possible values: yes|no|auto|download. For 'auto': If a BE User is |
| | | in, a debug information will be shown on the fronend. | | | | logged in, a debug information will be shown on the FE. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| REDIRECT_ALL_MAIL_TO | REDIRECT_ALL_MAIL_TO=john@doe.com | If set, redirect all QFQ generated mails (Form, Report) to the specified. | | REDIRECT_ALL_MAIL_TO | REDIRECT_ALL_MAIL_TO=john@doe.com | If set, redirect all QFQ generated mails (Form, Report) to the specified. |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
...@@ -250,6 +250,8 @@ config.qfq.ini ...@@ -250,6 +250,8 @@ config.qfq.ini
| CSS_CLASS_QFQ_CONTAINER |CSS_CLASS_QFQ_CONTAINER=container | QFQ with own Bootstrap: 'container'. | | CSS_CLASS_QFQ_CONTAINER |CSS_CLASS_QFQ_CONTAINER=container | QFQ with own Bootstrap: 'container'. |
| | | QFQ already nested in Bootstrap of mainpage: <empty> | | | | QFQ already nested in Bootstrap of mainpage: <empty> |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| CSS_CLASS_QFQ_FORM | CSS_CLASS_QFQ_FORM=qfq-color-base | Wrap around QFQ 'Form' |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| CSS_CLASS_QFQ_FORM_PILL |CSS_CLASS_QFQ_FORM_PILL=qfq-color-grey-1 | Wrap around title bar for pills: CSS Class, typically a background color | | CSS_CLASS_QFQ_FORM_PILL |CSS_CLASS_QFQ_FORM_PILL=qfq-color-grey-1 | Wrap around title bar for pills: CSS Class, typically a background color |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| CSS_CLASS_QFQ_FORM_BODY |CSS_CLASS_QFQ_FORM_BODY=qfq-color-grey-2 | Wrap around formelements: CSS Class, typically a background color | | CSS_CLASS_QFQ_FORM_BODY |CSS_CLASS_QFQ_FORM_BODY=qfq-color-grey-2 | Wrap around formelements: CSS Class, typically a background color |
...@@ -305,33 +307,36 @@ Example: *typo3conf/config.qfq.ini* ...@@ -305,33 +307,36 @@ Example: *typo3conf/config.qfq.ini*
DB_PASSWORD = 12345678 DB_PASSWORD = 12345678
DB_NAME = qfq_db DB_NAME = qfq_db
DB_INIT = set names utf8 DB_INIT = set names utf8
SQL_LOG = sql.log ; SQL_LOG = sql.log
SHOW_DEBUG_INFO = auto ; SQL_LOG_MODE = modify
; SHOW_DEBUG_INFO = auto
; REDIRECT_ALL_MAIL_TO = john.doe@example.com
CSS_LINK_CLASS_INTERNAL = internal CSS_LINK_CLASS_INTERNAL = internal
CSS_LINK_CLASS_EXT = external CSS_LINK_CLASS_EXT = external
;CSS_CLASS_QFQ_CONTAINER = ; CSS_CLASS_QFQ_CONTAINER =
;CSS_CLASS_QFQ_FORM = ; CSS_CLASS_QFQ_FORM =
CSS_CLASS_QFQ_FORM_PILL = qfq-color-grey-1 CSS_CLASS_QFQ_FORM_PILL = qfq-color-grey-1
CSS_CLASS_QFQ_FORM_BODY = qfq-color-grey-2 CSS_CLASS_QFQ_FORM_BODY = qfq-color-grey-2
;DATE_FORMAT= yyyy-mm-dd ; DATE_FORMAT= yyyy-mm-dd
;FORM_DATA_PATTERN_ERROR = ; TECHNICAL CONTACT = john@doe.com
;FORM_DATA_REQUIRED_ERROR = ; FORM_DATA_PATTERN_ERROR =
;FORM_DATA_MATCH_ERROR = ; FORM_DATA_REQUIRED_ERROR =
;FORM_DATA_ERROR = ; FORM_DATA_MATCH_ERROR =
;FORM_BS_COLUMNS = 12 ; FORM_DATA_ERROR =
;FORM_BS_LABEL_COLUMNS = 3 ; FORM_BS_COLUMNS = 12
;FORM_BS_INPUT_COLUMNS = 6 ; FORM_BS_LABEL_COLUMNS = 3
;FORM_BS_NOTE_COLUMNS = 3 ; FORM_BS_INPUT_COLUMNS = 6
BASE_URL_PRINT=http://example.com ; FORM_BS_NOTE_COLUMNS = 3
BASE_URL_PRINT=http://example.com/
WKHTMLTOPDF=/usr/bin/wkhtmltopdf WKHTMLTOPDF=/usr/bin/wkhtmltopdf
;EDIT_FORM_PAGE = form ; EDIT_FORM_PAGE = form
;LDAP_1_RDN='ou=Admin,dc=example,dc=com' ; LDAP_1_RDN='ou=Admin,dc=example,dc=com'
;LDAP_1_PASSWORD=mySecurePassword ; LDAP_1_PASSWORD=mySecurePassword
;ESCAPE_TYPE_DEFAULT=s ; ESCAPE_TYPE_DEFAULT=s
;SECURITY_VARS_HONEYPOT=email,username,password ; SECURITY_VARS_HONEYPOT=email,username,password
;SECURITY_ATTACK_DELAY=5 ; SECURITY_ATTACK_DELAY=5
;SECURITY_SHOW_MESSAGE=true ; SECURITY_SHOW_MESSAGE=true
;SECURITY_GET_MAX_LENGTH=32 ; SECURITY_GET_MAX_LENGTH=50
.. ..
...@@ -452,7 +457,11 @@ QFQ Keywords (Bodytext) ...@@ -452,7 +457,11 @@ QFQ Keywords (Bodytext)
+-------------------+---------------------------------------------------------------------------------+ +-------------------+---------------------------------------------------------------------------------+
| <level>.althead | If <level>.sql is empty, these token will be rendered | | <level>.althead | If <level>.sql is empty, these token will be rendered |
+-------------------+---------------------------------------------------------------------------------+ +-------------------+---------------------------------------------------------------------------------+
| debugShowBodyText | If='1' and config.qfq.ini:*SHOW_DEBUG_INFO =yes*, shows a tooltip with bodytext | | debugShowBodyText | If='1' and config.qfq.ini:*SHOW_DEBUG_INFO = yes*, shows a tooltip with bodytext|
+-------------------+---------------------------------------------------------------------------------+
| sqlLog | Overwrites config.qfq.ini: `SQL_LOG`_ . Only affects `Report`, not `Form`. |
+-------------------+---------------------------------------------------------------------------------+
| sqlLogMode | Overwrites config.qfq.ini: `SQL_LOG_MODE`_ . Only affects `Report`, not `Form`. |
+-------------------+---------------------------------------------------------------------------------+ +-------------------+---------------------------------------------------------------------------------+
.. _debug: .. _debug:
...@@ -460,9 +469,32 @@ QFQ Keywords (Bodytext) ...@@ -460,9 +469,32 @@ QFQ Keywords (Bodytext)
Debug Debug
^^^^^ ^^^^^
`config.qfq.ini`_ File: `config.qfq.ini`_
.. _SQL_LOG:
* *SQL_LOG*
* Filename where to log SQL queries and statistical data.
* File is relative to the extension directory or absolute (starting with '/').
* Content: SQL queries and timestamp, formName/formId, fe_user, success, affected rows, newly created record
id's and accessed from IP.
* The global setting can be overwritten by defining `sqlLog` inside of a QFQ tt-content record.
* *SHOW_DEBUG_INFO = yes|no|auto|download*
.. _SQL_LOG_MODE:
* *SQL_LOG_MODE = all|modify|error|none*
* *all*: logs every SQL statement.
* *modify*: logs only statements who might potentially change data.
* *error*: logs only queries which generate SQL errors.
* *none*: no query logging at all.
* The global setting can be overwritten by defining `sqlLogMode` inside of a QFQ tt-content record.
* *SHOW_DEBUG_INFO = [yes|no|auto],[download]*
If active, displays additional information in the Frontend (FE). This is typically helpful during development.
* *yes*: * *yes*:
...@@ -485,7 +517,7 @@ Debug ...@@ -485,7 +517,7 @@ Debug
* *download*: * *download*:
* During a download (especially by using wkhtml), temporary files are not deleted automatically. Also the * During a download (especially by using wkhtml), temporary files are not deleted automatically. Also the
`wkhtmltopdf` and `pdftk` commandlines will be logged to SQL_LOG. Use this only to debug problems on download. `wkhtmltopdf` and `pdftk` commandlines will be logged to `SQL_LOG`_. Use this only to debug problems on download.
.. _REDIRECT_ALL_MAIL_TO: .. _REDIRECT_ALL_MAIL_TO:
...@@ -605,6 +637,7 @@ Sanitize class ...@@ -605,6 +637,7 @@ Sanitize class
| **all** | Form | Query | no sanitizing | | **all** | Form | Query | no sanitizing |
+------------------+------+-------+-----------------------------------------------------------------------------------------+ +------------------+------+-------+-----------------------------------------------------------------------------------------+
..
Security Security
======== ========
...@@ -963,53 +996,53 @@ Store: *SYSTEM* - Y ...@@ -963,53 +996,53 @@ Store: *SYSTEM* - Y
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| Name | Explanation | | Name | Explanation |
+=========================+==========================================================================+ +=========================+==========================================================================+
| DB_USER | defined in config.ini | | DB_USER | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| DB_SERVER | defined in config.ini | | DB_SERVER | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| DB_NAME | defined in config.ini | | DB_NAME | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| DB_INIT | defined in config.ini | | DB_INIT | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| SQL_LOG | defined in config.ini | | SQL_LOG | defined in config.qfq.ini, see `SQL_LOG`_ |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| SQL_LOG_MODE | defined in config.ini | | SQL_LOG_MODE | defined in config.qfq.ini, `SQL_LOG_MODE`_ |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| SHOW_DEBUG_INFO | defined in config.ini | | SHOW_DEBUG_INFO | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| CSS_LINK_CLASS_INTERNAL | defined in config.ini | | CSS_LINK_CLASS_INTERNAL | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| CSS_LINK_CLASS_EXTERNAL | defined in config.ini | | CSS_LINK_CLASS_EXTERNAL | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| CSS_CLASS_QFQ_CONTAINER | defined in config.ini | | CSS_CLASS_QFQ_CONTAINER | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| EXT_PATH | computed during runtime | | EXT_PATH | computed during runtime |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| SITE_PATH | computed during runtime | | SITE_PATH | computed during runtime |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| DATE_FORMAT | defined in config.ini | | DATE_FORMAT | defined in config.qfq.ini |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| class | defined in config.ini (CSS_CLASS_QFQ_FORM) or form definition | | class | defined in config.qfq.ini (CSS_CLASS_QFQ_FORM) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| classPill | defined in config.ini (CSS_CLASS_QFQ_FORM_PILL) or form definition | | classPill | defined in config.qfq.ini (CSS_CLASS_QFQ_FORM_PILL) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| classBody | defined in config.ini (CSS_CLASS_QFQ_FORM_BODY) or form definition | | classBody | defined in config.qfq.ini (CSS_CLASS_QFQ_FORM_BODY) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| data-pattern-error | defined in config.ini or form definition | | data-pattern-error | defined in config.qfq.ini or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| data-require-error | defined in config.ini or form definition | | data-require-error | defined in config.qfq.ini or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| data-match-error | defined in config.ini or form definition | | data-match-error | defined in config.qfq.ini or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| data-error | defined in config.ini or form definition | | data-error | defined in config.qfq.ini or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| bsColumns | defined in config.ini (FORM_BS_COLUMNS) or form definition | | bsColumns | defined in config.qfq.ini (FORM_BS_COLUMNS) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| bsLabelColumns | defined in config.ini (FORM_BS_LABEL_COLUMNS) or form definition | | bsLabelColumns | defined in config.qfq.ini (FORM_BS_LABEL_COLUMNS) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| bsInputColumns | defined in config.ini (FORM_BS_INPUT_COLUMNS) or form definition | | bsInputColumns | defined in config.qfq.ini (FORM_BS_INPUT_COLUMNS) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| bsNoteColumns | defined in config.ini (FORM_BS_NOTE_COLUMNS) or form definition | | bsNoteColumns | defined in config.qfq.ini (FORM_BS_NOTE_COLUMNS) or form definition |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
| sqlFinal | computed during runtime, used for error reporting | | sqlFinal | computed during runtime, used for error reporting |
+-------------------------+--------------------------------------------------------------------------+ +-------------------------+--------------------------------------------------------------------------+
...@@ -2772,7 +2805,7 @@ Best for debugging is to specify in the tt-content record:: ...@@ -2772,7 +2805,7 @@ Best for debugging is to specify in the tt-content record::
debugShowBodyText = 1 debugShowBodyText = 1
Note: Debug information is only display if it's enabled in *config.ini* by Note: Debug information is only display if it's enabled in *config.qfq.ini* by
* *SHOW_DEBUG_INFO=yes* or * *SHOW_DEBUG_INFO=yes* or
* *SHOW_DEBUG_INFO=auto* and logged in in the same Browser as a Typo3 backend user. * *SHOW_DEBUG_INFO=auto* and logged in in the same Browser as a Typo3 backend user.
...@@ -3388,7 +3421,7 @@ The parsed bodytext could be displayed by activating 'SHOW_DEBUG_INFO ' (:ref:`d ...@@ -3388,7 +3421,7 @@ The parsed bodytext could be displayed by activating 'SHOW_DEBUG_INFO ' (:ref:`d
debugShowBodyText = 1 debugShowBodyText = 1
A small symbol with a tooltip will be shown, where the content record will be displayed on the webpage. A small symbol with a tooltip will be shown, where the content record will be displayed on the webpage.
Note: :ref:`debug` information will only be shown with *SHOW_DEBUG_INFO = yes* in config.ini . Note: :ref:`debug` information will only be shown with *SHOW_DEBUG_INFO = yes* in config.qfq.ini .
Structure Structure
--------- ---------
......
...@@ -12,7 +12,7 @@ DB_INIT = set names utf8 ...@@ -12,7 +12,7 @@ DB_INIT = set names utf8
; '../../sql.log' = <T3 Install directory>/typo3conf/sql.log ; '../../sql.log' = <T3 Install directory>/typo3conf/sql.log
SQL_LOG = ../../sql.log SQL_LOG = ../../sql.log
; all, modify ; all|modify|error|none
SQL_LOG_MODE = modify SQL_LOG_MODE = modify
; [auto|yes|no][,download]. 'auto': if BE User is logged in the value will be replaced by 'yes', else 'no'. Additional choose 'download'. ; [auto|yes|no][,download]. 'auto': if BE User is logged in the value will be replaced by 'yes', else 'no'. Additional choose 'download'.
...@@ -27,6 +27,7 @@ CSS_LINK_CLASS_EXTERNAL = external ...@@ -27,6 +27,7 @@ CSS_LINK_CLASS_EXTERNAL = external
;CSS_CLASS_QFQ_CONTAINER = ;CSS_CLASS_QFQ_CONTAINER =
; Default background color, specified via CSS class ; Default background color, specified via CSS class
;CSS_CLASS_QFQ_FORM =
CSS_CLASS_QFQ_FORM_PILL = qfq-color-grey-1 CSS_CLASS_QFQ_FORM_PILL = qfq-color-grey-1
CSS_CLASS_QFQ_FORM_BODY = qfq-color-grey-2 CSS_CLASS_QFQ_FORM_BODY = qfq-color-grey-2
......
...@@ -17,7 +17,8 @@ class BodytextParser { ...@@ -17,7 +17,8 @@ class BodytextParser {
/** /**
* @param $bodytext * @param $bodytext
* @return mixed * @return mixed|string
* @throws UserFormException
*/ */
public function process($bodytext) { public function process($bodytext) {
......
...@@ -316,6 +316,8 @@ const TYPO3_PAGE_ID = 'pageId'; ...@@ -316,6 +316,8 @@ const TYPO3_PAGE_ID = 'pageId';
const TYPO3_PAGE_TYPE = 'pageType'; const TYPO3_PAGE_TYPE = 'pageType';
const TYPO3_PAGE_LANGUAGE = 'pageLanguage'; const TYPO3_PAGE_LANGUAGE = 'pageLanguage';
const TYPO3_DEBUG_SHOW_BODY_TEXT = 'debugShowBodyText'; const TYPO3_DEBUG_SHOW_BODY_TEXT = 'debugShowBodyText';
const TYPO3_SQL_LOG = 'sqlLog';
const TYPO3_SQL_LOG_MODE = 'sqlLogMode';
// System // System
const SYSTEM_DB_USER = 'DB_USER'; const SYSTEM_DB_USER = 'DB_USER';
...@@ -325,6 +327,7 @@ const SYSTEM_DB_NAME = 'DB_NAME'; ...@@ -325,6 +327,7 @@ const SYSTEM_DB_NAME = 'DB_NAME';
const SYSTEM_DB_NAME_TEST = 'DB_NAME_TEST'; const SYSTEM_DB_NAME_TEST = 'DB_NAME_TEST';
const SYSTEM_DB_INIT = 'DB_INIT'; const SYSTEM_DB_INIT = 'DB_INIT';
const SYSTEM_SQL_LOG = 'SQL_LOG'; // Logging to file const SYSTEM_SQL_LOG = 'SQL_LOG'; // Logging to file
const SYSTEM_SQL_LOG_FILE = '../../sql.log';
const SYSTEM_SQL_LOG_MODE = 'SQL_LOG_MODE'; // Mode, which statements to log. const SYSTEM_SQL_LOG_MODE = 'SQL_LOG_MODE'; // Mode, which statements to log.
const SYSTEM_DATE_FORMAT = 'DATE_FORMAT'; const SYSTEM_DATE_FORMAT = 'DATE_FORMAT';
const SYSTEM_REDIRECT_ALL_MAIL_TO = 'REDIRECT_ALL_MAIL_TO'; const SYSTEM_REDIRECT_ALL_MAIL_TO = 'REDIRECT_ALL_MAIL_TO';
...@@ -487,7 +490,7 @@ const TOKEN_FORM = CLIENT_FORM; ...@@ -487,7 +490,7 @@ const TOKEN_FORM = CLIENT_FORM;
const TOKEN_RECORD_ID = CLIENT_RECORD_ID; const TOKEN_RECORD_ID = CLIENT_RECORD_ID;
const TOKEN_DEBUG_BODYTEXT = TYPO3_DEBUG_SHOW_BODY_TEXT; const TOKEN_DEBUG_BODYTEXT = TYPO3_DEBUG_SHOW_BODY_TEXT;
const TOKEN_VALID_LIST = 'sql|head|althead|tail|rbeg|rend|renr|rsep|fbeg|fend|fsep|rbgd|debug|form|r|debugShowBodyText'; const TOKEN_VALID_LIST = 'sql|head|althead|tail|rbeg|rend|renr|rsep|fbeg|fend|fsep|rbgd|debug|form|r|debugShowBodyText|sqlLog|sqlLogMode';
// FORM - copy from table 'form' of processed form // FORM - copy from table 'form' of processed form
//const DEF_FORM_NAME = CLIENT_FORM; //const DEF_FORM_NAME = CLIENT_FORM;
...@@ -498,7 +501,8 @@ const TOKEN_VALID_LIST = 'sql|head|althead|tail|rbeg|rend|renr|rsep|fbeg|fend|fs ...@@ -498,7 +501,8 @@ const TOKEN_VALID_LIST = 'sql|head|althead|tail|rbeg|rend|renr|rsep|fbeg|fend|fs
// SQL logging Modes // SQL logging Modes
const SQL_LOG_MODE_ALL = 'all'; const SQL_LOG_MODE_ALL = 'all';
const SQL_LOG_MODE_MODIFY = 'modify'; const SQL_LOG_MODE_MODIFY = 'modify';
const SQL_LOG_MODE_ERROR = 'error'; // write log entry, independent of global setting (e.g. broken Query) const SQL_LOG_MODE_NONE = 'none';
const SQL_LOG_MODE_ERROR = 'error';
const MODE_LDAP_PREFETCH = 'ldapPrefetch'; const MODE_LDAP_PREFETCH = 'ldapPrefetch';
const MODE_LDAP_SINGLE = 'ldapSingle'; const MODE_LDAP_SINGLE = 'ldapSingle';
......
...@@ -825,6 +825,7 @@ class QuickFormQuery { ...@@ -825,6 +825,7 @@ class QuickFormQuery {
* @return string * @return string
*/ */
private function doReport() { private function doReport() {
$report = new Report($this->t3data, $this->eval, $this->phpUnit); $report = new Report($this->t3data, $this->eval, $this->phpUnit);
$html = $report->process($this->t3data['bodytext']); $html = $report->process($this->t3data['bodytext']);
......
...@@ -56,6 +56,11 @@ class Database { ...@@ -56,6 +56,11 @@ class Database {
*/ */
private $sqlLog = ''; private $sqlLog = '';
/**
* @var array
*/
private $sqlLogModePrio = [SQL_LOG_MODE_NONE => 1, SQL_LOG_MODE_ERROR => 2, SQL_LOG_MODE_MODIFY => 3, SQL_LOG_MODE_ALL => 4];
/** /**
* Returns current data base handle from Store[System][SYSTEM_DBH]. * Returns current data base handle from Store[System][SYSTEM_DBH].
* If not exists: open database and store the new dbh in Store[System][SYSTEM_DBH] * If not exists: open database and store the new dbh in Store[System][SYSTEM_DBH]
...@@ -93,8 +98,6 @@ class Database { ...@@ -93,8 +98,6 @@ class Database {
} }
/** /**
* Open mysqli database connection if not already done. * Open mysqli database connection if not already done.
* *
...@@ -252,7 +255,7 @@ class Database { ...@@ -252,7 +255,7 @@ class Database {
*/ */
private function prepareExecute($sql, array $parameterArray = array(), &$queryType, array &$stat) { private function prepareExecute($sql, array $parameterArray = array(), &$queryType, array &$stat) {
$sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;; $sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;
$result = 0; $result = 0;
$stat = array(); $stat = array();
...@@ -346,7 +349,9 @@ class Database { ...@@ -346,7 +349,9 @@ class Database {
* @return bool true is the statement might modify data, else: false * @return bool true is the statement might modify data, else: false
*/ */
private function isSqlModify($sql) { private function isSqlModify($sql) {
$command = explode(' ', $sql, 2); $command = explode(' ', $sql, 2);
switch (strtoupper($command[0])) { switch (strtoupper($command[0])) {
case 'INSERT': case 'INSERT':
case 'UPDATE': case 'UPDATE':
...@@ -355,6 +360,7 @@ class Database { ...@@ -355,6 +360,7 @@ class Database {
case 'TRUNCATE': case 'TRUNCATE':
return true; return true;
} }
return false; return false;
} }
...@@ -366,27 +372,26 @@ class Database { ...@@ -366,27 +372,26 @@ class Database {
* @return string * @return string
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
private function dbLog($mode = SQL_LOG_MODE_ALL, $sql = '', $parameterArray = array()) { private function dbLog($currentQueryMode = SQL_LOG_MODE_ALL, $sql = '', $parameterArray = array()) {
$status = ''; $status = '';
$sqlLogMode = ($this->store === null) ? $this->store->getVar(SYSTEM_SQL_LOG_MODE, STORE_SYSTEM) : SQL_LOG_MODE_ERROR; // If no sqlLogMode is defined/available, choose SQL_LOG_MODE_ERROR
$sqlLogMode = $this->store->getVar(SYSTEM_SQL_LOG_MODE, STORE_SYSTEM);
switch ($mode) { if ($sqlLogMode === false) {
case SQL_LOG_MODE_ALL: $sqlLogMode = SQL_LOG_MODE_ERROR;
if ($sqlLogMode != SQL_LOG_MODE_ALL) { }
return;
}
break;
case SQL_LOG_MODE_MODIFY:
break;
case SQL_LOG_MODE_ERROR:
break;
default: // Check if string is known.
foreach ([$sqlLogMode, $currentQueryMode] as $mode) {
if (!isset($this->sqlLogModePrio[$mode])) {
throw new UserFormException("Unknown SQL_LOG_MODE: $mode", ERROR_UNKNOWN_SQL_LOG_MODE); throw new UserFormException("Unknown SQL_LOG_MODE: $mode", ERROR_UNKNOWN_SQL_LOG_MODE);
}
}
// Log?
if ($this->sqlLogModePrio[$sqlLogMode] < ($this->sqlLogModePrio[$currentQueryMode])) {
return;
} }
// Client IP Address // Client IP Address
...@@ -404,7 +409,7 @@ class Database { ...@@ -404,7 +409,7 @@ class Database {
} }
if ($sql !== '') { if ($sql !== '') {
if ($mode == SQL_LOG_MODE_ERROR) { if ($currentQueryMode == SQL_LOG_MODE_ERROR) {
$status = 'FAILED: '; $status = 'FAILED: ';
} }
$msg .= '[' . $status . $sql . ']'; $msg .= '[' . $status . $sql . ']';
......
...@@ -22,6 +22,10 @@ class Logger { ...@@ -22,6 +22,10 @@ class Logger {
*/ */
public static function logMessage($msg, $filename) { public static function logMessage($msg, $filename) {
if ($filename == '') {
return;
}
if (!$handle = fopen($filename, 'a')) { if (!$handle = fopen($filename, 'a')) {
throw new UserFormException("Error - cannot open. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_OPEN); throw new UserFormException("Error - cannot open. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_OPEN);
} }
......
...@@ -107,6 +107,8 @@ class Report { ...@@ -107,6 +107,8 @@ class Report {
$this->showDebugInfoFlag = (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))); $this->showDebugInfoFlag = (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM)));
$this->checkUpdateSqlLog();
$this->pageDefaults[DEFAULT_QUESTION]["pagec"] = "Please confirm!:info"; $this->pageDefaults[DEFAULT_QUESTION]["pagec"] = "Please confirm!:info";
$this->pageDefaults[DEFAULT_QUESTION]["paged"] = "Do you really want to delete the record?:warning"; $this->pageDefaults[DEFAULT_QUESTION]["paged"] = "Do you really want to delete the record?:warning";
...@@ -131,6 +133,26 @@ class Report { ...@@ -131,6 +133,26 @@ class Report {
} }
/**
* If a variable 'sqlLog' is given in STORE_TYPO3 (=Bodytext) make them relative to SYSTEM_PATH_EXT and copy it to STORE_SYSTEM
*/
private function checkUpdateSqlLog() {
$sqlLog = $this->store->getVar(TYPO3_SQL_LOG, STORE_TYPO3);
if (false !== $sqlLog) {
if ($sqlLog != '' && $sqlLog[0] !== '/') {
$sqlLog = $this->store->getVar(SYSTEM_PATH_EXT, STORE_SYSTEM) . '/' . $sqlLog;
}
$this->store->setVar(SYSTEM_SQL_LOG, $sqlLog, STORE_SYSTEM);
}
$sqlLogMode = $this->store->getVar(TYPO3_SQL_LOG_MODE, STORE_TYPO3);
if (false !== $sqlLogMode) {
$this->store->setVar(SYSTEM_SQL_LOG_MODE, $sqlLogMode, STORE_SYSTEM);
}
}