Aleksander Machniak
2015-02-20 c7b77b9179f1fcb52ed5f4d6b648daa54eeda7b4
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.
2 files modified
24 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_db_mysql.php 23 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -9,6 +9,7 @@
- Fix setting max packet size for DB caches and check packet size also in shared cache
- Fix needless security warning on BMP attachments display (#1490282)
- Fix handling of some improper constructs in format=flowed text as per the RFC3676[4.5] (#1490284)
- Fix performance of rcube_db_mysql::get_variable()
RELEASE 1.1.0
-------------
program/lib/Roundcube/rcube_db_mysql.php
@@ -161,15 +161,24 @@
    {
        if (!isset($this->variables)) {
            $this->variables = array();
            $result = $this->query('SHOW VARIABLES');
            while ($row = $this->fetch_array($result)) {
                $this->variables[$row[0]] = $row[1];
            }
        }
        return isset($this->variables[$varname]) ? $this->variables[$varname] : $default;
        if (array_key_exists($varname, $this->variables)) {
            return $this->variables[$varname];
        }
        $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 $this->variables[$varname];
    }
    /**