summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2015-02-20 04:33:34 -0500
committerAleksander Machniak <alec@alec.pl>2015-02-20 04:33:34 -0500
commitc7b77b9179f1fcb52ed5f4d6b648daa54eeda7b4 (patch)
tree3169fe5199eb4bb8cd49c820913a1a116abeb04b /program/lib/Roundcube
parent13e0a6556ffa9e0b3257f08d78042a8133055ea3 (diff)
Fix performance of rcube_db_mysql::get_variable()
As currently we're using this to find only max_allowed_packet value, it is better to use "SHOW VARIABLES LIKE ?" instead of asking for all variables.
Diffstat (limited to 'program/lib/Roundcube')
-rw-r--r--program/lib/Roundcube/rcube_db_mysql.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/program/lib/Roundcube/rcube_db_mysql.php b/program/lib/Roundcube/rcube_db_mysql.php
index 0e85b0f9c..067e94be6 100644
--- a/program/lib/Roundcube/rcube_db_mysql.php
+++ b/program/lib/Roundcube/rcube_db_mysql.php
@@ -161,15 +161,24 @@ class rcube_db_mysql extends rcube_db
{
if (!isset($this->variables)) {
$this->variables = array();
+ }
- $result = $this->query('SHOW VARIABLES');
+ if (array_key_exists($varname, $this->variables)) {
+ return $this->variables[$varname];
+ }
- while ($row = $this->fetch_array($result)) {
- $this->variables[$row[0]] = $row[1];
- }
+ $result = $this->query('SHOW VARIABLES LIKE ?', $varname);
+
+ while ($row = $this->fetch_array($result)) {
+ $this->variables[$row[0]] = $row[1];
+ }
+
+ // not found, use default
+ if (!isset($this->variables[$varname])) {
+ $this->variables[$varname] = $default;
}
- return isset($this->variables[$varname]) ? $this->variables[$varname] : $default;
+ return $this->variables[$varname];
}
/**