mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- DibiProfiler: added some limits for Firebug
This commit is contained in:
@@ -29,6 +29,12 @@
|
|||||||
*/
|
*/
|
||||||
class DibiProfiler extends DibiObject implements IDibiProfiler
|
class DibiProfiler extends DibiObject implements IDibiProfiler
|
||||||
{
|
{
|
||||||
|
/** maximum number of rows */
|
||||||
|
const FIREBUG_MAX_ROWS = 30;
|
||||||
|
|
||||||
|
/** maximum SQL length */
|
||||||
|
const FIREBUG_MAX_LENGTH = 500;
|
||||||
|
|
||||||
/** @var string Name of the file where SQL errors should be logged */
|
/** @var string Name of the file where SQL errors should be logged */
|
||||||
private $file;
|
private $file;
|
||||||
|
|
||||||
@@ -104,6 +110,7 @@ class DibiProfiler extends DibiObject implements IDibiProfiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
list($connection, $event, $sql) = $this->tickets[$ticket];
|
list($connection, $event, $sql) = $this->tickets[$ticket];
|
||||||
|
$sql = trim($sql);
|
||||||
|
|
||||||
if (($event & $this->filter) === 0) return;
|
if (($event & $this->filter) === 0) return;
|
||||||
|
|
||||||
@@ -115,12 +122,14 @@ class DibiProfiler extends DibiObject implements IDibiProfiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->useFirebug && !headers_sent()) {
|
if ($this->useFirebug && !headers_sent()) {
|
||||||
|
if (count(self::$table) < self::FIREBUG_MAX_ROWS) {
|
||||||
self::$table[] = array(
|
self::$table[] = array(
|
||||||
sprintf('%0.3f', dibi::$elapsedTime * 1000),
|
sprintf('%0.3f', dibi::$elapsedTime * 1000),
|
||||||
trim($sql),
|
strlen($sql) > self::FIREBUG_MAX_LENGTH ? substr($sql, 0, self::FIREBUG_MAX_LENGTH) . '...' : $sql,
|
||||||
$count,
|
$count,
|
||||||
$connection->getConfig('driver') . '/' . $connection->getConfig('name')
|
$connection->getConfig('driver') . '/' . $connection->getConfig('name')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
||||||
header('X-Wf-dibi-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0');
|
header('X-Wf-dibi-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0');
|
||||||
|
Reference in New Issue
Block a user