From f33ea1151e776d2d0e30ec9ad8128385a7407a0d Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Mon, 21 Jan 2008 14:40:32 +0000 Subject: [PATCH] oops, of course cache per server --- libraries/check_user_privileges.lib.php | 23 ++++++++------- libraries/common.lib.php | 9 +++--- libraries/database_interface.lib.php | 26 ++++++++++------- libraries/mysql_charsets.lib.php | 38 ++++++++++++------------- 4 files changed, 51 insertions(+), 45 deletions(-) diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index 22fb4409d..49854d4af 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -37,6 +37,7 @@ $GLOBALS['is_superuser'] = PMA_isSuperuser(); * @uses $GLOBALS['is_reload_priv'] to set it * @uses $GLOBALS['db_to_create'] to set it * @uses $GLOBALS['dbs_where_create_table_allowed'] to set it + * @uses $GLOBALS['server'] * @uses PMA_DBI_try_query() * @uses PMA_DBI_fetch_row() * @uses PMA_DBI_free_result() @@ -50,13 +51,13 @@ $GLOBALS['is_superuser'] = PMA_isSuperuser(); */ function PMA_analyseShowGrant() { - if (isset($_SESSION['is_create_db_priv'])) { - $GLOBALS['is_create_db_priv'] = $_SESSION['is_create_db_priv']; - $GLOBALS['is_process_priv'] = $_SESSION['is_create_db_priv']; - $GLOBALS['is_reload_priv'] = $_SESSION['is_create_db_priv']; - $GLOBALS['db_to_create'] = $_SESSION['is_create_db_priv']; + if (isset($_SESSION[$GLOBALS['server']]['is_create_db_priv'])) { + $GLOBALS['is_create_db_priv'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv']; + $GLOBALS['is_process_priv'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv']; + $GLOBALS['is_reload_priv'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv']; + $GLOBALS['db_to_create'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv']; $GLOBALS['dbs_where_create_table_allowed'] - = $_SESSION['is_create_db_priv']; + = $_SESSION[$GLOBALS['server']]['is_create_db_priv']; return; } @@ -143,11 +144,11 @@ function PMA_analyseShowGrant() PMA_DBI_free_result($rs_usr); - $_SESSION['is_create_db_priv'] = $GLOBALS['is_create_db_priv']; - $_SESSION['is_process_priv'] = $GLOBALS['is_create_db_priv']; - $_SESSION['is_reload_priv'] = $GLOBALS['is_create_db_priv']; - $_SESSION['db_to_create'] = $GLOBALS['is_create_db_priv']; - $_SESSION['dbs_where_create_table_allowed'] + $_SESSION[$GLOBALS['server']]['is_create_db_priv'] = $GLOBALS['is_create_db_priv']; + $_SESSION[$GLOBALS['server']]['is_process_priv'] = $GLOBALS['is_create_db_priv']; + $_SESSION[$GLOBALS['server']]['is_reload_priv'] = $GLOBALS['is_create_db_priv']; + $_SESSION[$GLOBALS['server']]['db_to_create'] = $GLOBALS['is_create_db_priv']; + $_SESSION[$GLOBALS['server']]['dbs_where_create_table_allowed'] = $GLOBALS['is_create_db_priv']; } // end function diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 6fa45dc3e..2a087a173 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1201,6 +1201,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice') * Verifies if current MySQL server supports profiling * * @uses $_SESSION['profiling_supported'] for caching + * @uses $GLOBALS['server'] * @uses PMA_DBI_fetch_value() * @uses PMA_MYSQL_INT_VERSION * @uses defined() @@ -1211,20 +1212,20 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice') */ function PMA_profilingSupported() { - if (! isset($_SESSION['profiling_supported'])) { + if (! isset($_SESSION[$GLOBALS['server']]['profiling_supported'])) { // 5.0.37 has profiling but for example, 5.1.20 does not // (avoid a trip to the server for MySQL before 5.0.37) // and do not set a constant as we might be switching servers if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 50037 && PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) { - $_SESSION['profiling_supported'] = true; + $_SESSION[$GLOBALS['server']]['profiling_supported'] = true; } else { - $_SESSION['profiling_supported'] = false; + $_SESSION[$GLOBALS['server']]['profiling_supported'] = false; } } - return $_SESSION['profiling_supported']; + return $_SESSION[$GLOBALS['server']]['profiling_supported']; } /** diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index a1e829276..0d6092ccd 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -779,8 +779,10 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null /** * @uses ./libraries/charset_conversion.lib.php * @uses PMA_DBI_QUERY_STORE - * @uses PMA_MYSQL_INT_VERSION - * @uses PMA_MYSQL_STR_VERSION + * @uses PMA_MYSQL_INT_VERSION to set it + * @uses PMA_MYSQL_STR_VERSION to set it + * @uses $_SESSION['PMA_MYSQL_INT_VERSION'] for caching + * @uses $_SESSION['PMA_MYSQL_STR_VERSION'] for caching * @uses PMA_DBI_GETVAR_SESSION * @uses PMA_DBI_fetch_value() * @uses PMA_DBI_query() @@ -790,6 +792,7 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null * @uses $GLOBALS['mysql_charset_map'] * @uses $GLOBALS['charset'] * @uses $GLOBALS['lang'] + * @uses $GLOBALS['server'] * @uses $GLOBALS['cfg']['Lang'] * @uses defined() * @uses explode() @@ -806,8 +809,8 @@ function PMA_DBI_postConnect($link, $is_controluser = false) { if (! defined('PMA_MYSQL_INT_VERSION')) { if (isset($_SESSION['PMA_MYSQL_INT_VERSION'])) { - define('PMA_MYSQL_INT_VERSION', $_SESSION['PMA_MYSQL_INT_VERSION']); - define('PMA_MYSQL_STR_VERSION', $_SESSION['PMA_MYSQL_STR_VERSION']); + define('PMA_MYSQL_INT_VERSION', $_SESSION[$GLOBALS['server']]['PMA_MYSQL_INT_VERSION']); + define('PMA_MYSQL_STR_VERSION', $_SESSION[$GLOBALS['server']]['PMA_MYSQL_STR_VERSION']); } else { $mysql_version = PMA_DBI_fetch_value( 'SELECT VERSION()', 0, 0, $link, PMA_DBI_QUERY_STORE); @@ -822,8 +825,8 @@ function PMA_DBI_postConnect($link, $is_controluser = false) define('PMA_MYSQL_INT_VERSION', 50015); define('PMA_MYSQL_STR_VERSION', '5.00.15'); } - $_SESSION['PMA_MYSQL_INT_VERSION'] = PMA_MYSQL_INT_VERSION; - $_SESSION['PMA_MYSQL_STR_VERSION'] = PMA_MYSQL_STR_VERSION; + $_SESSION[$GLOBALS['server']]['PMA_MYSQL_INT_VERSION'] = PMA_MYSQL_INT_VERSION; + $_SESSION[$GLOBALS['server']]['PMA_MYSQL_STR_VERSION'] = PMA_MYSQL_STR_VERSION; } } @@ -1158,26 +1161,27 @@ function PMA_DBI_get_warnings($link = null) * * @uses $_SESSION['is_superuser'] for caching * @uses $GLOBALS['userlink'] + * @uses $GLOBALS['server'] * @uses PMA_DBI_try_query() * @uses PMA_DBI_QUERY_STORE * @return integer $is_superuser */ function PMA_isSuperuser() { - if (isset($_SESSION['is_superuser'])) { - return $_SESSION['is_superuser']; + if (isset($_SESSION[$GLOBALS['server']]['is_superuser'])) { + return $_SESSION[$GLOBALS['server']]['is_superuser']; } // with mysql extension, when connection failed we don't have // a $userlink if (isset($GLOBALS['userlink'])) { - $_SESSION['is_superuser'] = (bool) PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', + $_SESSION[$GLOBALS['server']]['is_superuser'] = (bool) PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $GLOBALS['userlink'], PMA_DBI_QUERY_STORE); } else { - $_SESSION['is_superuser'] = false; + $_SESSION[$GLOBALS['server']]['is_superuser'] = false; } - return $_SESSION['is_superuser']; + return $_SESSION[$GLOBALS['server']]['is_superuser']; } /** diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index 2d44a249a..f95619a98 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -9,7 +9,7 @@ * */ -if (! isset($_SESSION['mysql_charsets_count'])) { +if (! isset($_SESSION[$GLOBALS['server']]['mysql_charsets_count'])) { $res = PMA_DBI_query('SHOW CHARACTER SET;'); $mysql_charsets = array(); @@ -55,25 +55,25 @@ if (! isset($_SESSION['mysql_charsets_count'])) { } unset($key, $value); - $_SESSION['mysql_charsets'] = $GLOBALS['mysql_charsets']; - $_SESSION['mysql_charsets_descriptions'] = $GLOBALS['mysql_charsets_descriptions']; - $_SESSION['mysql_charsets_count'] = $GLOBALS['mysql_charsets_count']; - $_SESSION['mysql_charsets_available'] = $GLOBALS['mysql_charsets_available']; - $_SESSION['mysql_collations'] = $GLOBALS['mysql_collations']; - $_SESSION['mysql_default_collations'] = $GLOBALS['mysql_default_collations']; - $_SESSION['mysql_collations_flat'] = $GLOBALS['mysql_collations_flat']; - $_SESSION['mysql_collations_count'] = $GLOBALS['mysql_collations_count']; - $_SESSION['mysql_collations_available'] = $GLOBALS['mysql_collations_available']; + $_SESSION[$GLOBALS['server']]['mysql_charsets'] = $GLOBALS['mysql_charsets']; + $_SESSION[$GLOBALS['server']]['mysql_charsets_descriptions'] = $GLOBALS['mysql_charsets_descriptions']; + $_SESSION[$GLOBALS['server']]['mysql_charsets_count'] = $GLOBALS['mysql_charsets_count']; + $_SESSION[$GLOBALS['server']]['mysql_charsets_available'] = $GLOBALS['mysql_charsets_available']; + $_SESSION[$GLOBALS['server']]['mysql_collations'] = $GLOBALS['mysql_collations']; + $_SESSION[$GLOBALS['server']]['mysql_default_collations'] = $GLOBALS['mysql_default_collations']; + $_SESSION[$GLOBALS['server']]['mysql_collations_flat'] = $GLOBALS['mysql_collations_flat']; + $_SESSION[$GLOBALS['server']]['mysql_collations_count'] = $GLOBALS['mysql_collations_count']; + $_SESSION[$GLOBALS['server']]['mysql_collations_available'] = $GLOBALS['mysql_collations_available']; } else { - $GLOBALS['mysql_charsets'] = $_SESSION['mysql_charsets']; - $GLOBALS['mysql_charsets_descriptions'] = $_SESSION['mysql_charsets_descriptions']; - $GLOBALS['mysql_charsets_count'] = $_SESSION['mysql_charsets_count']; - $GLOBALS['mysql_charsets_available'] = $_SESSION['mysql_charsets_available']; - $GLOBALS['mysql_collations'] = $_SESSION['mysql_collations']; - $GLOBALS['mysql_default_collations'] = $_SESSION['mysql_default_collations']; - $GLOBALS['mysql_collations_flat'] = $_SESSION['mysql_collations_flat']; - $GLOBALS['mysql_collations_count'] = $_SESSION['mysql_collations_count']; - $GLOBALS['mysql_collations_available'] = $_SESSION['mysql_collations_available']; + $GLOBALS['mysql_charsets'] = $_SESSION[$GLOBALS['server']]['mysql_charsets']; + $GLOBALS['mysql_charsets_descriptions'] = $_SESSION[$GLOBALS['server']]['mysql_charsets_descriptions']; + $GLOBALS['mysql_charsets_count'] = $_SESSION[$GLOBALS['server']]['mysql_charsets_count']; + $GLOBALS['mysql_charsets_available'] = $_SESSION[$GLOBALS['server']]['mysql_charsets_available']; + $GLOBALS['mysql_collations'] = $_SESSION[$GLOBALS['server']]['mysql_collations']; + $GLOBALS['mysql_default_collations'] = $_SESSION[$GLOBALS['server']]['mysql_default_collations']; + $GLOBALS['mysql_collations_flat'] = $_SESSION[$GLOBALS['server']]['mysql_collations_flat']; + $GLOBALS['mysql_collations_count'] = $_SESSION[$GLOBALS['server']]['mysql_collations_count']; + $GLOBALS['mysql_collations_available'] = $_SESSION[$GLOBALS['server']]['mysql_collations_available']; } define('PMA_CSDROPDOWN_COLLATION', 0);