1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Avoid displaying more than 500 sql queries during debug mode. (eg. when poorly written plugins are in use)

This commit is contained in:
Cameron 2017-01-07 10:30:21 -08:00
parent 999119b5ba
commit 8d2adfa719

View File

@ -264,21 +264,36 @@ class e107_db_debug {
// Optionally list good queries
//
if ($okCount && E107_DBG_SQLDETAILS) {
if ($okCount && E107_DBG_SQLDETAILS)
{
$text .= "\n<table class='fborder table table-striped table-bordered'>\n";
$text .= "<tr><td class='fcaption' colspan='3'><b>".$this->countLabel($okCount)." Good Queries</b></td></tr>\n";
$text .= "<tr><td class='fcaption'><b>Index</b></td><td class='fcaption'><b>Qtime</b></td><td class='fcaption'><b>Query</b></td></tr>\n
<tr><td class='fcaption'>&nbsp;</td><td class='fcaption'><b>(msec)</b></td><td class='fcaption'>&nbsp;</td></tr>\n
";
$count = 0;
foreach ($this->aSQLdetails as $idx => $cQuery)
{
if ($cQuery['ok']) {
if($count > 500)
{
$text .= "<tr class='danger'><td colspan='6'><b>Too many queries. Ending... </b></td></tr>"; // NO LAN - debug only.
break;
}
if ($cQuery['ok'])
{
$text .= "<tr><td class='forumheader3' style='text-align:right'>{$idx}&nbsp;</td>
<td class='forumheader3' style='text-align:right'>".number_format($cQuery['time'] * 1000.0, 4)."&nbsp;</td>
<td class='forumheader3'>".$cQuery['query'].'<br />['.$cQuery['marker']." - ".$cQuery['caller']."]</td></tr>\n";
$count++;
}
}
$text .= "\n</table><br />\n";
}
@ -286,8 +301,11 @@ class e107_db_debug {
//
// Optionally list query details
//
if (E107_DBG_SQLDETAILS) {
foreach ($this->aSQLdetails as $idx => $cQuery) {
if (E107_DBG_SQLDETAILS)
{
$count = 0;
foreach ($this->aSQLdetails as $idx => $cQuery)
{
$text .= "\n<table class='fborder table table-striped table-bordered' style='width: 100%;'>\n";
$text .= "<tr><td class='forumheader3' colspan='".$cQuery['nFields']."'><b>".$idx.") Query:</b> [".$cQuery['marker']." - ".$cQuery['caller']."]<br />".$cQuery['query']."</td></tr>\n";
if (isset($cQuery['explain'])) {
@ -300,6 +318,15 @@ class e107_db_debug {
$text .= "<tr><td class='forumheader3' colspan='".$cQuery['nFields']."'><b>Query time:</b> ".number_format($cQuery['time'] * 1000.0, 4).' (ms)</td></tr>';
$text .= '</table><br />'."\n";
if($count > 500)
{
$text .= "<div class='alert alert-danger text-center'>Too many queries. Ending...</div>"; // NO LAN - debug only.
break;
}
$count++;
}
}