From 9b8d22ebe14a2a6d3f5c8bebee0a3126a72521cc Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 8 May 2013 20:19:58 +0200 Subject: Limit debug log entry (line) size to 4096 characters to prevent memory_limit/preformance issues when debug is enabled (imap, smtp, db) --- program/lib/Roundcube/rcube_db.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'program/lib/Roundcube/rcube_db.php') 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 . ';'); } } -- cgit v1.2.3