summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_imap_generic.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_imap_generic.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_imap_generic.php')
-rw-r--r--program/lib/Roundcube/rcube_imap_generic.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 6c1b85552..1d2a9be16 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -72,6 +72,8 @@ class rcube_imap_generic
const COMMAND_CAPABILITY = 2;
const COMMAND_LASTLINE = 4;
+ const DEBUG_LINE_LENGTH = 4096;
+
/**
* Object constructor
*/
@@ -3757,9 +3759,10 @@ class rcube_imap_generic
/**
* Set the value of the debugging flag.
*
- * @param boolean $debug New value for the debugging flag.
+ * @param boolean $debug New value for the debugging flag.
+ * @param callback $handler Logging handler function
*
- * @since 0.5-stable
+ * @since 0.5-stable
*/
function setDebug($debug, $handler = null)
{
@@ -3770,12 +3773,17 @@ class rcube_imap_generic
/**
* Write the given debug text to the current debug output handler.
*
- * @param string $message Debug mesage text.
+ * @param string $message Debug mesage text.
*
- * @since 0.5-stable
+ * @since 0.5-stable
*/
private function debug($message)
{
+ if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) {
+ $message = substr_replace($message, "\n-----[debug cut]-----\n",
+ self::DEBUG_LINE_LENGTH/2 - 11, $len - self::DEBUG_LINE_LENGTH - 22);
+ }
+
if ($this->resourceid) {
$message = sprintf('[%s] %s', $this->resourceid, $message);
}