Project

General

Profile

Feature #15897 ยป bug_2988.diff

Administrator Admin, 2008-01-31 12:16

View differences:

t3lib/class.t3lib_timetrack.php (Arbeitskopie)
* @param string Message/Label to attach
* @return void
*/
function setTSselectQuery($query,$msg) {
function setTSselectQuery($data,$msg='') {
end($this->currentHashPointer);
$k = current($this->currentHashPointer);
$this->tsStackLog[$k]['selectQuery'][] = array('query'=>$query,'msg'=>$msg);
if (strlen($msg)) {
$data['msg'] = $msg;
}
$this->tsStackLog[$k]['selectQuery'][] = $data;
}
/**
......
}
}
if ($flag_queries && is_array($data['selectQuery'])) {
reset($data['selectQuery']);
while(list(,$v)=each($data['selectQuery'])) {
$res = $GLOBALS['TYPO3_DB']->sql_query('EXPLAIN '.$v['query']);
$v['mysql_error'] = $GLOBALS['TYPO3_DB']->sql_error();
if (!$GLOBALS['TYPO3_DB']->sql_error()) {
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$v['explain'][]=$row;
}
}
$msgArr[] = t3lib_div::view_array($v);
}
$msgArr[] = t3lib_div::view_array($data['selectQuery']);
}
if ($flag_content && strcmp($data['content'],'')) {
$maxlen = 120;
t3lib/class.t3lib_db.php (Arbeitskopie)
var $debugOutput = FALSE; // Set "TRUE" if you want database errors outputted.
var $debug_lastBuiltQuery = ''; // Internally: Set to last built query (not necessarily executed...)
var $store_lastBuiltQuery = FALSE; // Set "TRUE" if you want the last built query to be stored in $debug_lastBuiltQuery independent of $this->debugOutput
var $explainOutput = 0; // Set this to 1 to get queries explained (devIPmask must match). Set the value to 2 to the same but disregarding the devIPmask. There is an alternative option to enable explain output in the admin panel under "TypoScript", which will produce much nicer output, but only works in FE.
// Default link identifier:
var $link = FALSE;
......
* @return pointer MySQL result pointer / DBAL object
*/
function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='') {
$res = mysql_query($this->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit), $this->link);
if ($this->debugOutput) $this->debug('exec_SELECTquery');
$query = $this->SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit);
$res = mysql_query($query, $this->link);
if ($this->debugOutput) $this->debug('exec_SELECTquery');
if ($this->explainOutput) $this->explain($query, $this->sql_num_rows($res));
return $res;
}
......
return TRUE;
}
/**
* Explain select queries
* If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed.
* The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!)
*
* TODO: Feature is not DBAL-compliant
*
* @param string SQL query
* @param integer Number of resulting rows
* @return boolean True if explain was run, false otherwise
*/
function explain($query,$row_count) {
if ((int)$this->explainOutput==1 || ((int)$this->explainOutput==2 && t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']))) {
$explainMode = 1; // raw HTML output
} elseif ((int)$this->explainOutput==3 && is_object($GLOBALS['TT'])) {
$explainMode = 2; // embed the output into the TS admin panel
} else {
return false;
}
$error = $GLOBALS['TYPO3_DB']->sql_error();
$trail = t3lib_div::debug_trail();
$explain_output = array();
$res = mysql_query('EXPLAIN '.$query, $this->link);
if ($res) {
while ($tempRow = $this->sql_fetch_assoc($res)) {
$explain_output[] = $tempRow;
}
}
$indices_output = array();
if ($explain_output[0]['rows']>1 || t3lib_div::inList('ALL',$explain_output[0]['type'])) {
$debug = true; // only enable output if it's really useful
$res = mysql_query('SHOW INDEX FROM '.$from_table, $this->link);
if ($res) {
while ($tempRow = $this->sql_fetch_assoc($res)) {
$indices_output[] = $tempRow;
}
}
} else $debug = false;
if ($debug) {
if ($explainMode==1) {
t3lib_div::debug('QUERY: '.$query);
t3lib_div::debug(array('Debug trail:'=>$trail), 'Row count: '.$row_count);
if ($error) {
t3lib_div::debug($error);
}
if (count($explain_output)) {
t3lib_div::debug($explain_output);
}
if (count($indices_output)) {
t3lib_div::debugRows($indices_output);
}
} elseif ($explainMode==2) {
$data = array();
$data['query'] = $query;
$data['trail'] = $trail;
$data['row_count'] = $row_count;
if ($error) {
$data['error'] = $error;
}
if (count($explain_output)) {
$data['explain'] = $explain_output;
}
if (count($indices_output)) {
$data['indices'] = $indices;
}
$GLOBALS['TT']->setTSselectQuery($data);
}
return true;
}
return false;
}
}
typo3/sysext/cms/tslib/index_ts.php (Arbeitskopie)
$TSFE->displayEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayIcons');
$TSFE->displayFieldEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayFieldIcons');
if ($BE_USER->extGetFeAdminValue('tsdebug','displayQueries')) {
if ($GLOBALS['TYPO3_DB']->explainOutput == 0) { // do not override if the value is already set in t3lib_db
// Enable execution of EXPLAIN SELECT queries
$GLOBALS['TYPO3_DB']->explainOutput = 3;
}
}
if (t3lib_div::_GP('ADMCMD_editIcons')) {
$TSFE->displayFieldEditIcons=1;
$BE_USER->uc['TSFE_adminConfig']['edit_editNoPopup']=1;
    (1-1/1)