oops, of course cache per server

This commit is contained in:
Sebastian Mendel
2008-01-21 14:40:32 +00:00
parent d4d008cd17
commit f33ea1151e
4 changed files with 51 additions and 45 deletions

View File

@@ -37,6 +37,7 @@ $GLOBALS['is_superuser'] = PMA_isSuperuser();
* @uses $GLOBALS['is_reload_priv'] to set it * @uses $GLOBALS['is_reload_priv'] to set it
* @uses $GLOBALS['db_to_create'] to set it * @uses $GLOBALS['db_to_create'] to set it
* @uses $GLOBALS['dbs_where_create_table_allowed'] to set it * @uses $GLOBALS['dbs_where_create_table_allowed'] to set it
* @uses $GLOBALS['server']
* @uses PMA_DBI_try_query() * @uses PMA_DBI_try_query()
* @uses PMA_DBI_fetch_row() * @uses PMA_DBI_fetch_row()
* @uses PMA_DBI_free_result() * @uses PMA_DBI_free_result()
@@ -50,13 +51,13 @@ $GLOBALS['is_superuser'] = PMA_isSuperuser();
*/ */
function PMA_analyseShowGrant() function PMA_analyseShowGrant()
{ {
if (isset($_SESSION['is_create_db_priv'])) { if (isset($_SESSION[$GLOBALS['server']]['is_create_db_priv'])) {
$GLOBALS['is_create_db_priv'] = $_SESSION['is_create_db_priv']; $GLOBALS['is_create_db_priv'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv'];
$GLOBALS['is_process_priv'] = $_SESSION['is_create_db_priv']; $GLOBALS['is_process_priv'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv'];
$GLOBALS['is_reload_priv'] = $_SESSION['is_create_db_priv']; $GLOBALS['is_reload_priv'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv'];
$GLOBALS['db_to_create'] = $_SESSION['is_create_db_priv']; $GLOBALS['db_to_create'] = $_SESSION[$GLOBALS['server']]['is_create_db_priv'];
$GLOBALS['dbs_where_create_table_allowed'] $GLOBALS['dbs_where_create_table_allowed']
= $_SESSION['is_create_db_priv']; = $_SESSION[$GLOBALS['server']]['is_create_db_priv'];
return; return;
} }
@@ -143,11 +144,11 @@ function PMA_analyseShowGrant()
PMA_DBI_free_result($rs_usr); PMA_DBI_free_result($rs_usr);
$_SESSION['is_create_db_priv'] = $GLOBALS['is_create_db_priv']; $_SESSION[$GLOBALS['server']]['is_create_db_priv'] = $GLOBALS['is_create_db_priv'];
$_SESSION['is_process_priv'] = $GLOBALS['is_create_db_priv']; $_SESSION[$GLOBALS['server']]['is_process_priv'] = $GLOBALS['is_create_db_priv'];
$_SESSION['is_reload_priv'] = $GLOBALS['is_create_db_priv']; $_SESSION[$GLOBALS['server']]['is_reload_priv'] = $GLOBALS['is_create_db_priv'];
$_SESSION['db_to_create'] = $GLOBALS['is_create_db_priv']; $_SESSION[$GLOBALS['server']]['db_to_create'] = $GLOBALS['is_create_db_priv'];
$_SESSION['dbs_where_create_table_allowed'] $_SESSION[$GLOBALS['server']]['dbs_where_create_table_allowed']
= $GLOBALS['is_create_db_priv']; = $GLOBALS['is_create_db_priv'];
} // end function } // end function

View File

@@ -1201,6 +1201,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice')
* Verifies if current MySQL server supports profiling * Verifies if current MySQL server supports profiling
* *
* @uses $_SESSION['profiling_supported'] for caching * @uses $_SESSION['profiling_supported'] for caching
* @uses $GLOBALS['server']
* @uses PMA_DBI_fetch_value() * @uses PMA_DBI_fetch_value()
* @uses PMA_MYSQL_INT_VERSION * @uses PMA_MYSQL_INT_VERSION
* @uses defined() * @uses defined()
@@ -1211,20 +1212,20 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice')
*/ */
function PMA_profilingSupported() 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 // 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) // (avoid a trip to the server for MySQL before 5.0.37)
// and do not set a constant as we might be switching servers // and do not set a constant as we might be switching servers
if (defined('PMA_MYSQL_INT_VERSION') if (defined('PMA_MYSQL_INT_VERSION')
&& PMA_MYSQL_INT_VERSION >= 50037 && PMA_MYSQL_INT_VERSION >= 50037
&& PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) { && PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) {
$_SESSION['profiling_supported'] = true; $_SESSION[$GLOBALS['server']]['profiling_supported'] = true;
} else { } else {
$_SESSION['profiling_supported'] = false; $_SESSION[$GLOBALS['server']]['profiling_supported'] = false;
} }
} }
return $_SESSION['profiling_supported']; return $_SESSION[$GLOBALS['server']]['profiling_supported'];
} }
/** /**

View File

@@ -779,8 +779,10 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null
/** /**
* @uses ./libraries/charset_conversion.lib.php * @uses ./libraries/charset_conversion.lib.php
* @uses PMA_DBI_QUERY_STORE * @uses PMA_DBI_QUERY_STORE
* @uses PMA_MYSQL_INT_VERSION * @uses PMA_MYSQL_INT_VERSION to set it
* @uses PMA_MYSQL_STR_VERSION * @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_GETVAR_SESSION
* @uses PMA_DBI_fetch_value() * @uses PMA_DBI_fetch_value()
* @uses PMA_DBI_query() * @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['mysql_charset_map']
* @uses $GLOBALS['charset'] * @uses $GLOBALS['charset']
* @uses $GLOBALS['lang'] * @uses $GLOBALS['lang']
* @uses $GLOBALS['server']
* @uses $GLOBALS['cfg']['Lang'] * @uses $GLOBALS['cfg']['Lang']
* @uses defined() * @uses defined()
* @uses explode() * @uses explode()
@@ -806,8 +809,8 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
{ {
if (! defined('PMA_MYSQL_INT_VERSION')) { if (! defined('PMA_MYSQL_INT_VERSION')) {
if (isset($_SESSION['PMA_MYSQL_INT_VERSION'])) { if (isset($_SESSION['PMA_MYSQL_INT_VERSION'])) {
define('PMA_MYSQL_INT_VERSION', $_SESSION['PMA_MYSQL_INT_VERSION']); define('PMA_MYSQL_INT_VERSION', $_SESSION[$GLOBALS['server']]['PMA_MYSQL_INT_VERSION']);
define('PMA_MYSQL_STR_VERSION', $_SESSION['PMA_MYSQL_STR_VERSION']); define('PMA_MYSQL_STR_VERSION', $_SESSION[$GLOBALS['server']]['PMA_MYSQL_STR_VERSION']);
} else { } else {
$mysql_version = PMA_DBI_fetch_value( $mysql_version = PMA_DBI_fetch_value(
'SELECT VERSION()', 0, 0, $link, PMA_DBI_QUERY_STORE); '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_INT_VERSION', 50015);
define('PMA_MYSQL_STR_VERSION', '5.00.15'); define('PMA_MYSQL_STR_VERSION', '5.00.15');
} }
$_SESSION['PMA_MYSQL_INT_VERSION'] = PMA_MYSQL_INT_VERSION; $_SESSION[$GLOBALS['server']]['PMA_MYSQL_INT_VERSION'] = PMA_MYSQL_INT_VERSION;
$_SESSION['PMA_MYSQL_STR_VERSION'] = PMA_MYSQL_STR_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 $_SESSION['is_superuser'] for caching
* @uses $GLOBALS['userlink'] * @uses $GLOBALS['userlink']
* @uses $GLOBALS['server']
* @uses PMA_DBI_try_query() * @uses PMA_DBI_try_query()
* @uses PMA_DBI_QUERY_STORE * @uses PMA_DBI_QUERY_STORE
* @return integer $is_superuser * @return integer $is_superuser
*/ */
function PMA_isSuperuser() function PMA_isSuperuser()
{ {
if (isset($_SESSION['is_superuser'])) { if (isset($_SESSION[$GLOBALS['server']]['is_superuser'])) {
return $_SESSION['is_superuser']; return $_SESSION[$GLOBALS['server']]['is_superuser'];
} }
// with mysql extension, when connection failed we don't have // with mysql extension, when connection failed we don't have
// a $userlink // a $userlink
if (isset($GLOBALS['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); $GLOBALS['userlink'], PMA_DBI_QUERY_STORE);
} else { } else {
$_SESSION['is_superuser'] = false; $_SESSION[$GLOBALS['server']]['is_superuser'] = false;
} }
return $_SESSION['is_superuser']; return $_SESSION[$GLOBALS['server']]['is_superuser'];
} }
/** /**

View File

@@ -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;'); $res = PMA_DBI_query('SHOW CHARACTER SET;');
$mysql_charsets = array(); $mysql_charsets = array();
@@ -55,25 +55,25 @@ if (! isset($_SESSION['mysql_charsets_count'])) {
} }
unset($key, $value); unset($key, $value);
$_SESSION['mysql_charsets'] = $GLOBALS['mysql_charsets']; $_SESSION[$GLOBALS['server']]['mysql_charsets'] = $GLOBALS['mysql_charsets'];
$_SESSION['mysql_charsets_descriptions'] = $GLOBALS['mysql_charsets_descriptions']; $_SESSION[$GLOBALS['server']]['mysql_charsets_descriptions'] = $GLOBALS['mysql_charsets_descriptions'];
$_SESSION['mysql_charsets_count'] = $GLOBALS['mysql_charsets_count']; $_SESSION[$GLOBALS['server']]['mysql_charsets_count'] = $GLOBALS['mysql_charsets_count'];
$_SESSION['mysql_charsets_available'] = $GLOBALS['mysql_charsets_available']; $_SESSION[$GLOBALS['server']]['mysql_charsets_available'] = $GLOBALS['mysql_charsets_available'];
$_SESSION['mysql_collations'] = $GLOBALS['mysql_collations']; $_SESSION[$GLOBALS['server']]['mysql_collations'] = $GLOBALS['mysql_collations'];
$_SESSION['mysql_default_collations'] = $GLOBALS['mysql_default_collations']; $_SESSION[$GLOBALS['server']]['mysql_default_collations'] = $GLOBALS['mysql_default_collations'];
$_SESSION['mysql_collations_flat'] = $GLOBALS['mysql_collations_flat']; $_SESSION[$GLOBALS['server']]['mysql_collations_flat'] = $GLOBALS['mysql_collations_flat'];
$_SESSION['mysql_collations_count'] = $GLOBALS['mysql_collations_count']; $_SESSION[$GLOBALS['server']]['mysql_collations_count'] = $GLOBALS['mysql_collations_count'];
$_SESSION['mysql_collations_available'] = $GLOBALS['mysql_collations_available']; $_SESSION[$GLOBALS['server']]['mysql_collations_available'] = $GLOBALS['mysql_collations_available'];
} else { } else {
$GLOBALS['mysql_charsets'] = $_SESSION['mysql_charsets']; $GLOBALS['mysql_charsets'] = $_SESSION[$GLOBALS['server']]['mysql_charsets'];
$GLOBALS['mysql_charsets_descriptions'] = $_SESSION['mysql_charsets_descriptions']; $GLOBALS['mysql_charsets_descriptions'] = $_SESSION[$GLOBALS['server']]['mysql_charsets_descriptions'];
$GLOBALS['mysql_charsets_count'] = $_SESSION['mysql_charsets_count']; $GLOBALS['mysql_charsets_count'] = $_SESSION[$GLOBALS['server']]['mysql_charsets_count'];
$GLOBALS['mysql_charsets_available'] = $_SESSION['mysql_charsets_available']; $GLOBALS['mysql_charsets_available'] = $_SESSION[$GLOBALS['server']]['mysql_charsets_available'];
$GLOBALS['mysql_collations'] = $_SESSION['mysql_collations']; $GLOBALS['mysql_collations'] = $_SESSION[$GLOBALS['server']]['mysql_collations'];
$GLOBALS['mysql_default_collations'] = $_SESSION['mysql_default_collations']; $GLOBALS['mysql_default_collations'] = $_SESSION[$GLOBALS['server']]['mysql_default_collations'];
$GLOBALS['mysql_collations_flat'] = $_SESSION['mysql_collations_flat']; $GLOBALS['mysql_collations_flat'] = $_SESSION[$GLOBALS['server']]['mysql_collations_flat'];
$GLOBALS['mysql_collations_count'] = $_SESSION['mysql_collations_count']; $GLOBALS['mysql_collations_count'] = $_SESSION[$GLOBALS['server']]['mysql_collations_count'];
$GLOBALS['mysql_collations_available'] = $_SESSION['mysql_collations_available']; $GLOBALS['mysql_collations_available'] = $_SESSION[$GLOBALS['server']]['mysql_collations_available'];
} }
define('PMA_CSDROPDOWN_COLLATION', 0); define('PMA_CSDROPDOWN_COLLATION', 0);