summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_db.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-08 20:19:58 +0200
committerAleksander Machniak <alec@alec.pl>2013-05-08 20:19:58 +0200
commit9b8d22ebe14a2a6d3f5c8bebee0a3126a72521cc (patch)
treeafee4436eee3e7bf1a4c7e258d2b51d8edbffb00 /program/lib/Roundcube/rcube_db.php
parenta522971cf853b2f0ccd1b569491a06218ebbaee9 (diff)
Limit debug log entry (line) size to 4096 characters to prevent
memory_limit/preformance issues when debug is enabled (imap, smtp, db)
Diffstat (limited to 'program/lib/Roundcube/rcube_db.php')
-rw-r--r--program/lib/Roundcube/rcube_db.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 4b9ab131c..f8a9bdc37 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -47,6 +47,7 @@ class rcube_db
'identifier_end' => '"',
);
+ const DEBUG_LINE_LENGTH = 4096;
/**
* Factory, returns driver-specific instance of the class
@@ -255,6 +256,10 @@ class rcube_db
protected function debug($query)
{
if ($this->options['debug_mode']) {
+ if (($len = strlen($query)) > self::DEBUG_LINE_LENGTH) {
+ $query = substr_replace($query, "\n-----[debug cut]-----\n",
+ self::DEBUG_LINE_LENGTH/2 - 11, $len - self::DEBUG_LINE_LENGTH - 22);
+ }
rcube::write_log('sql', '[' . (++$this->db_index) . '] ' . $query . ';');
}
}