From ab84cc15e5cb708b91b70bd81b96adc712e312d3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 25 Feb 2015 21:08:16 +0100 Subject: [PATCH] Reset default db_max_allowed_packet, fix max packet size detection --- config/defaults.inc.php | 2 +- program/lib/Roundcube/rcube_cache.php | 6 ++++-- program/lib/Roundcube/rcube_cache_shared.php | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/defaults.inc.php b/config/defaults.inc.php index edc5b32df..50c392db3 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -55,7 +55,7 @@ $config['db_table_dsn'] = array( // Use them if your server is not MySQL or for better performance. // For example Roundcube uses max_allowed_packet value (in bytes) // which limits query size for database cache operations. -$config['db_max_allowed_packet'] = 23423440; +$config['db_max_allowed_packet'] = null; // ---------------------------------- diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php index 52a2db997..303abdac4 100644 --- a/program/lib/Roundcube/rcube_cache.php +++ b/program/lib/Roundcube/rcube_cache.php @@ -605,8 +605,10 @@ class rcube_cache $this->max_packet = 2097152; // default/max is 2 MB if ($this->type == 'db') { - $value = $this->db->get_variable('max_allowed_packet', $this->max_packet); - $this->max_packet = max($value, $this->max_packet) - 2000; + if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) { + $this->max_packet = $value; + } + $this->max_packet -= 2000; } else if ($this->type == 'memcache') { $stats = $this->db->getStats(); diff --git a/program/lib/Roundcube/rcube_cache_shared.php b/program/lib/Roundcube/rcube_cache_shared.php index 339a9aa20..3f0f20e41 100644 --- a/program/lib/Roundcube/rcube_cache_shared.php +++ b/program/lib/Roundcube/rcube_cache_shared.php @@ -595,8 +595,10 @@ class rcube_cache_shared $this->max_packet = 2097152; // default/max is 2 MB if ($this->type == 'db') { - $value = $this->db->get_variable('max_allowed_packet', 1048500); - $this->max_packet = min($value, $this->max_packet) - 2000; + if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) { + $this->max_packet = $value; + } + $this->max_packet -= 2000; } else if ($this->type == 'memcache') { $stats = $this->db->getStats();