38 $this->MOD_MENU = array(
40 0 =>
$GLOBALS[
'LANG']->getLL(
'Debug_log'),
41 'info' =>
$GLOBALS[
'LANG']->getLL(
'Cached_info'),
42 'sqlcheck' =>
$GLOBALS[
'LANG']->getLL(
'SQL_check')
59 $this->doc->backPath =
$GLOBALS[
'BACK_PATH'];
60 $this->doc->form =
'<form action="" method="post">';
62 $this->content .= $this->doc->startPage(
$GLOBALS[
'LANG']->getLL(
'title'));
63 $this->content .= $this->doc->header(
$GLOBALS[
'LANG']->getLL(
'title'));
64 $this->content .= $this->doc->spacer(5);
65 $this->content .= $this->doc->section(
'', $this->doc->funcMenu(
'',
BackendUtility::getFuncMenu(0,
'SET[function]', $this->MOD_SETTINGS[
'function'], $this->MOD_MENU[
'function'])));
67 switch ($this->MOD_SETTINGS[
'function']) {
75 $this->content .= $this->doc->section(
$GLOBALS[
'LANG']->getLL(
'Debug_log'), $this->
printLogMgm());
79 if (
$GLOBALS[
'BE_USER']->mayMakeShortcut()) {
80 $this->content .= $this->doc->spacer(20) . $this->doc->section(
'', $this->doc->makeShortcutIcon(
'id', implode(
',', array_keys($this->MOD_MENU)), $this->MCONF[
'name']));
82 $this->content .= $this->doc->spacer(10);
91 $this->content .= $this->doc->endPage();
103 <form name="sql_check" action="' . $this->thisScript .
'" method="post" enctype="' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'form_enctype'] .
'"> 104 <script type="text/javascript"> 106 function updateQryForm(s) { 107 document.getElementById(\'tx-dbal-result\').style.display = \'none\'; 110 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'none\'; 111 document.getElementById(\'tx-dbal-qryfields\').style.display = \'table-row\'; 112 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\'; 113 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\'; 114 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\'; 115 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\'; 116 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\'; 117 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\'; 118 document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\'; 119 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\'; 122 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'none\'; 123 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\'; 124 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'table-row\'; 125 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\'; 126 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\'; 127 document.getElementById(\'tx-dbal-qryinto\').style.display = \'table-row\'; 128 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\'; 129 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\'; 130 document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\'; 131 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\'; 134 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'table-row\'; 135 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\'; 136 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\'; 137 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'table-row\'; 138 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\'; 139 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\'; 140 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'table-row\'; 141 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\'; 142 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\'; 143 document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\'; 144 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\'; 147 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'none\'; 148 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\'; 149 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\'; 150 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\'; 151 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\'; 152 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\'; 153 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\'; 154 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\'; 155 document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\'; 156 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\'; 163 <tr class="tableheader bgColor5"><th colspan="2">Easy SQL check</th></tr> 165 <select name="tx_dbal[QUERY]"size="1" onchange="updateQryForm(this.options[this.selectedIndex].value)"> 166 <option value="SELECT" ' . ($input[
'QUERY'] ===
'SELECT' ?
'selected="selected"' :
'') .
'>SELECT</option> 167 <option value="INSERT" ' . ($input[
'QUERY'] ===
'INSERT' ?
'selected="selected"' :
'') .
'>INSERT</option> 168 <option value="UPDATE" ' . ($input[
'QUERY'] ===
'UPDATE' ?
'selected="selected"' :
'') .
'>UPDATE</option> 169 <option value="DELETE" ' . ($input[
'QUERY'] ===
'DELETE' ?
'selected="selected"' :
'') .
'>DELETE</option> 172 <tr id="tx-dbal-qryupdate" style="display:none;"><td></td><td><input name="tx_dbal[UPDATE]" value="' . $input[
'UPDATE'] .
'" type="text" size="30" maxsize="100" /></td></tr> 173 <tr id="tx-dbal-qryfields"><td></td><td><input name="tx_dbal[FIELDS]" value="' . $input[
'FIELDS'] .
'" type="text" size="30" maxsize="100" /></td></tr> 174 <tr id="tx-dbal-qryinsertvalues" style="display:none;"><td></td><td><textarea name="tx_dbal[INSERTVALUES]" cols="30" rows="4">' . $input[
'INSERTVALUES'] .
'</textarea></td></tr> 175 <tr id="tx-dbal-qryupdatevalues" style="display:none;"><th>SET</th><td><textarea name="tx_dbal[UPDATEVALUES]" cols="30" rows="4">' . $input[
'UPDATEVALUES'] .
'</textarea></td></tr> 176 <tr id="tx-dbal-qryfrom"><th>FROM</th><td><input name="tx_dbal[FROM]" value="' . $input[
'FROM'] .
'" type="text" size="30" maxsize="100" /></td></tr> 177 <tr id="tx-dbal-qryinto" style="display:none;"><th>INTO</th><td><input name="tx_dbal[INTO]" value="' . $input[
'INTO'] .
'" type="text" size="30" maxsize="100" /></td></tr> 178 <tr id="tx-dbal-qrywhere"><th>WHERE</th><td><input name="tx_dbal[WHERE]" value="' . $input[
'WHERE'] .
'" type="text" size="30" maxsize="100" /></td></tr> 179 <tr id="tx-dbal-qrygroup"><th>GROUP BY</th><td><input name="tx_dbal[GROUP]" value="' . $input[
'GROUP'] .
'" type="text" size="30" maxsize="100" /></td></tr> 180 <tr id="tx-dbal-qryorder"><th>ORDER BY</th><td><input name="tx_dbal[ORDER]" value="' . $input[
'ORDER'] .
'" type="text" size="30" maxsize="100" /></td></tr> 181 <tr id="tx-dbal-qrylimit"><th>LIMIT</th><td><input name="tx_dbal[LIMIT]" value="' . $input[
'LIMIT'] .
'" type="text" size="30" maxsize="100" /></td></tr> 182 <tr><td></td><td style="text-align:right;"><input type="submit" value="CHECK" /></td></tr> 183 <script type="text/javascript"> 185 updateQryForm(\'' . $input[
'QUERY'] .
'\');
189 $out .= '<tr
id=
"tx-dbal-result" class=
"bgColor4"><th>Result:</th><td>
'; 190 switch ($input['QUERY
']) { 192 $qry = $GLOBALS['TYPO3_DB
']->SELECTquery($input['FIELDS
'], $input['FROM
'], $input['WHERE
'], $input['GROUP
'], $input['ORDER
'], $input['LIMIT
']); 195 $qry = $GLOBALS['TYPO3_DB
']->INSERTquery($input['INTO
'], $this->createFieldsValuesArray($input['INSERTVALUES
'])); 198 $qry = $GLOBALS['TYPO3_DB
']->UPDATEquery($input['UPDATE
'], $input['WHERE
'], $this->createFieldsValuesArray($input['UPDATEVALUES
'])); 201 $qry = $GLOBALS['TYPO3_DB
']->DELETEquery($input['FROM
'], $input['WHERE
']); 204 $out .= '<pre>
' . htmlspecialchars($qry) . '</pre></td></tr>
'; 206 <tr
class=
"tableheader bgColor5"><th colspan=
"2">RAW SQL check</th></tr>
207 <tr><td colspan=
"2" style=
"text-align:right;"><textarea name=
"tx_dbal[RAWSQL]" cols=
"60" rows=
"5">
' . $input['RAWSQL
'] . '</textarea><br /><input type=
"submit" value=
"CHECK" /></td></tr>
'; 208 if (!empty($input['RAWSQL
'])) { 209 $out .= '<tr
class=
"bgColor4">
'; 210 $parseResult = $GLOBALS['TYPO3_DB
']->SQLparser->parseSQL($input['RAWSQL
']); 211 if (is_array($parseResult)) { 212 $newQuery = $GLOBALS['TYPO3_DB
']->SQLparser->compileSQL($parseResult); 213 $testResult = $GLOBALS['TYPO3_DB
']->SQLparser->debug_parseSQLpartCompare($input['RAWSQL
'], $newQuery); 214 if (!is_array($testResult)) { 215 $out .= '<td colspan=
"2">
' . $newQuery; 217 $out .= '<td colspan=
"2">
' . htmlspecialchars($testResult[0]) . '</td></tr>
218 <tr><th>Error:</th><td style=
"border:2px solid #f00;">Input query did not match the parsed and recompiled query exactly (not observing whitespace):<br />
' . htmlspecialchars($testResult[1]); 221 $out .= '<th>Result:</th><td style=
"border:2px solid #f00;">
' . $parseResult; 223 $out .= '</td></tr>
'; 225 $out .= '</table></form>
'; 238 protected function createFieldsValuesArray($in) { 240 $in = explode(chr(10), $in); 241 foreach ($in as $v) { 242 $fv = explode('=
', $v); 243 $ret[$fv[0]] = $fv[1]; 257 protected function printCachedInfo() { 259 if ((string) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cmd
') === 'clear
') { 260 $GLOBALS['TYPO3_DB
']->clearCachedFieldInfo(); 261 $GLOBALS['TYPO3_DB
']->cacheFieldInfo(); 263 $out = '<a name=
"autoincrement"></a><h2>auto_increment</h2>
'; 264 $out .= '<table border=
"1" cellspacing=
"0"><tbody><tr><th>Table</th><th>Field</th></tr>
'; 265 ksort($GLOBALS['TYPO3_DB
']->cache_autoIncFields); 266 foreach ($GLOBALS['TYPO3_DB
']->cache_autoIncFields as $table => $field) { 268 $out .= '<td>
' . $table . '</td>
'; 269 $out .= '<td>
' . $field . '</td>
'; 272 $out .= '</tbody></table>
'; 273 $out .= $this->doc->spacer(5); 274 $out .= '<a name=
"primarykeys"></a><h2>Primary keys</h2>
'; 275 $out .= '<table border=
"1" cellspacing=
"0"><tbody><tr><th>Table</th><th>Field(s)</th></tr>
'; 276 ksort($GLOBALS['TYPO3_DB
']->cache_primaryKeys); 277 foreach ($GLOBALS['TYPO3_DB
']->cache_primaryKeys as $table => $field) { 279 $out .= '<td>
' . $table . '</td>
'; 280 $out .= '<td>
' . $field . '</td>
'; 283 $out .= '</tbody></table>
'; 284 $out .= $this->doc->spacer(5); 285 $out .= '<a name=
"fieldtypes"></a><h2>Field types</h2>
'; 286 $out .= '<table border=
"1" cellspacing=
"0"><tbody><tr><th colspan=
"5">Table</th></tr><tr><th>Field</th><th>Type</th><th><a href=
"#metatypes">Metatype</a></th><th>NOT NULL</th><th>Default</th></th></tr>
'; 287 ksort($GLOBALS['TYPO3_DB
']->cache_fieldType); 288 foreach ($GLOBALS['TYPO3_DB
']->cache_fieldType as $table => $fields) { 289 $out .= '<th colspan=
"5">
' . $table . '</th>
'; 290 foreach ($fields as $field => $data) { 292 $out .= '<td>
' . $field . '</td>
'; 293 $out .= '<td>
' . $data['type
'] . '</td>
'; 294 $out .= '<td>
' . $data['metaType
'] . '</td>
'; 295 $out .= '<td>
' . ($data['notnull
'] ? 'NOT NULL
' : '') . '</td>
'; 296 $out .= '<td>
' . $data['default'] . '</td>
'; 300 $out .= '</tbody></table>
'; 301 $out .= $this->doc->spacer(5); 302 $out .= '<a name=
"metatypes"></a><h2>Metatype explanation</h2>
'; 304 C: Varchar, capped to 255 characters.
305 X: Larger varchar, capped to 4000 characters (to be compatible with Oracle).
306 XL: For Oracle, returns CLOB, otherwise the largest varchar size.
308 C2: Multibyte varchar
309 X2: Multibyte varchar (largest size)
311 B: BLOB (binary large
object)
313 D: Date (some databases
do not support
this, and we
return a datetime type)
314 T: Datetime or Timestamp
315 L: Integer field suitable
for storing booleans (0 or 1)
316 I: Integer (mapped to I4)
321 F: Floating point number
322 N: Numeric or decimal number</pre>
'; 323 $menu = '<a href=
"' . $this->thisScript . '&cmd=clear">CLEAR DATA</a><hr />
'; 324 $menu .= '<a href=
"#autoincrement">auto_increment</a> | <a href=
"#primarykeys">Primary keys</a> | <a href=
"#fieldtypes">Field types</a> | <a href=
"#metatypes">Metatype explanation</a><hr />
'; 335 protected function printLogMgm() { 336 // Disable debugging in any case... 337 $GLOBALS['TYPO3_DB
']->debug = FALSE; 339 $cmd = (string) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cmd
'); 342 $res = $GLOBALS['TYPO3_DB
']->exec_TRUNCATEquery('tx_dbal_debuglog
'); 343 $res = $GLOBALS['TYPO3_DB
']->exec_TRUNCATEquery('tx_dbal_debuglog_where
'); 344 $outStr = 'Log FLUSHED!
'; 347 $res = $GLOBALS['TYPO3_DB
']->exec_SELECTquery('table_join,exec_time,query,script
', 'tx_dbal_debuglog
', 'table_join!=\
'\'',
'table_join,script,exec_time,query');
349 $tableIndex = array();
353 <td>Execution time</td> 358 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
359 $tableArray =
$GLOBALS[
'TYPO3_DB']->SQLparser->parseFromTables($row[
'table_join']);
361 foreach ($tableArray as $a) {
362 foreach ($tableArray as $b) {
363 if ($b[
'table'] != $a[
'table']) {
364 $tableIndex[$a[
'table']][$b[
'table']] = 1;
371 <td>' . htmlspecialchars($row[
'exec_time']) .
'</td> 372 <td>' . htmlspecialchars($row[
'table_join']) .
'</td> 373 <td>' . htmlspecialchars($row[
'script']) .
'</td> 374 <td>' . htmlspecialchars($row[
'query']) .
'</td> 380 foreach ($tableIndex as $priTable => $a) {
381 foreach ($tableIndex as $tableN => $v) {
382 foreach ($v as $tableP => $vv) {
383 if ($tableP == $priTable) {
384 $tableIndex[$priTable] = array_merge($v, $a);
392 <table border="1" cellspacing="0">' . implode(
'', $tRows) .
' 396 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'serdata,exec_time,query,script',
'tx_dbal_debuglog',
'errorFlag>0',
'',
'tstamp DESC');
401 <td>Execution time</td> 406 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
410 <td>' . htmlspecialchars($row[
'exec_time']) .
'</td> 412 <td>' . htmlspecialchars($row[
'script']) .
'</td> 413 <td>' . htmlspecialchars($row[
'query']) .
'</td> 418 <table border="1" cellspacing="0">' . implode(
'', $tRows) .
' 422 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'query,serdata',
'tx_dbal_debuglog',
'errorFlag&2=2');
424 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
428 <td>' . htmlspecialchars($row[
'query']) .
'</td> 433 <table border="1" cellspacing="0">' . implode(
'', $tRows) .
' 437 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'tstamp,script,tablename,whereclause',
'tx_dbal_debuglog_where',
'',
'',
'tstamp DESC');
444 <td>WHERE clause</td> 446 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
450 <td>' . htmlspecialchars($row[
'script']) .
'</td> 451 <td>' . htmlspecialchars($row[
'tablename']) .
'</td> 452 <td>' . str_replace(array(
'\'\
'',
'""',
'IS NULL',
'IS NOT NULL'), array(
'<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>',
'<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>',
'<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>',
'<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row[
'whereclause'])) .
'</td> 456 <table border="1" cellspacing="0">' . implode(
'', $tRows) .
' 463 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'exec_time,errorFlag,table_join,serdata,query',
'tx_dbal_debuglog',
'tstamp=' . (
int)$specTime);
467 <td>Execution time</td> 473 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
476 <td>' . htmlspecialchars($row[
'exec_time']) .
'</td> 477 <td>' . ($row[
'errorFlag'] ? 1 : 0) .
'</td> 478 <td>' . htmlspecialchars($row[
'table_join']) .
'</td> 480 <td>' . str_replace(array(
'\'\
'',
'""',
'IS NULL',
'IS NOT NULL'), array(
'<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>',
'<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>',
'<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>',
'<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row[
'query'])) .
'</td> 484 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'tstamp,script, SUM(exec_time) as calc_sum, count(*) AS qrycount, MAX(errorFlag) as error',
'tx_dbal_debuglog',
'',
'tstamp,script',
'tstamp DESC');
489 <td># of queries</td> 494 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
498 <td>' . htmlspecialchars($row[
'qrycount']) .
'</td> 499 <td>' . ($row[
'error'] ?
'<strong style="color:#f00">ERR</strong>' :
'') .
'</td> 500 <td>' . htmlspecialchars($row[
'calc_sum']) .
'</td> 501 <td><a href="' . $this->thisScript .
'&specTime=' . (int)$row[
'tstamp'] .
'">' . htmlspecialchars($row[
'script']) .
'</a></td> 506 <table border="1" cellspacing="0">' . implode(
'', $tRows) .
' 510 <a href="' . $this->thisScript .
'&cmd=flush">FLUSH LOG</a> - 511 <a href="' . $this->thisScript .
'&cmd=joins">JOINS</a> - 512 <a href="' . $this->thisScript .
'&cmd=errors">ERRORS</a> - 513 <a href="' . $this->thisScript .
'&cmd=parsing">PARSING</a> - 514 <a href="' . $this->thisScript .
'">LOG</a> - 515 <a href="' . $this->thisScript .
'&cmd=where">WHERE</a> - 517 <a href="' . htmlspecialchars(\
TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript()) .
'" target="tx_debuglog">[New window]</a> 520 return $menu . $outStr;
static makeInstance($className)
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static viewArray($array_in)
static getFuncMenu($mainParams, $elementName, $currentValue, $menuItems, $script='', $addparams='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]