diff --git a/ChangeLog b/ChangeLog index 2cf4e29b0..d83e3d577 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA - patch #1821154, HTTP authentication: fix auth working with php/mod_fastcgi, thanks to yarodin - wrong default charset in case of broken session +- bug #1824506 [profiling] Profile command repeated on older MySQL servers 2.11.2.0 (2007-10-27) - patch #1791576 HTTP auth: support REDIRECT_REMOTE_USER, thanks to Allard diff --git a/libraries/common.inc.php b/libraries/common.inc.php index a7c120bbb..acfa839ba 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -906,11 +906,11 @@ if (! defined('PMA_MINIMUM_COMMON')) { * (note: when $cfg['ServerDefault'] = 0, constant is not defined) */ - if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 50037 && isset($_REQUEST['profiling'])) { - $_SESSION['profiling'] = true; + if (PMA_profilingSupported() && isset($_REQUEST['profiling'])) { + $_SESSION['profiling'] = true; } elseif (isset($_REQUEST['profiling_form'])) { - // the checkbox was unchecked - unset($_SESSION['profiling']); + // the checkbox was unchecked + unset($_SESSION['profiling']); } } // end if !defined('PMA_MINIMUM_COMMON') diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 89cc48d62..2eb400519 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1223,6 +1223,24 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice') echo '
' . "\n"; } // end of the 'PMA_showMessage()' function +/** + * Verifies if current MySQL server supports profiling + * + * @access public + * @return boolean whether profiling is supported + * + * @author Marc Delisle + */ +function PMA_profilingSupported() { + // 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 (PMA_MYSQL_INT_VERSION >= 50037 && PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) { + return true; + } else { + return false; + } +} /** * Displays a form with the Profiling checkbox @@ -1233,9 +1251,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice') * @author Marc Delisle */ function PMA_profilingCheckbox($sql_query) { - // 5.0.37 has profiling but for example, 5.1.20 does not - // (avoid doing a fetch_value for MySQL before 5.0.37) - if (PMA_MYSQL_INT_VERSION >= 50037 && PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) { + if (PMA_profilingSupported()) { echo '
' . "\n"; echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); echo '' . "\n"; diff --git a/sql.php b/sql.php index f2f4e5b82..0eab30fc8 100644 --- a/sql.php +++ b/sql.php @@ -290,7 +290,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { unset($result); $num_rows = 0; } else { - if (isset($_SESSION['profiling'])) { + if (isset($_SESSION['profiling']) && PMA_profilingSupported()) { PMA_DBI_query('SET PROFILING=1;'); } @@ -335,7 +335,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { } // Grabs the profiling results - if (isset($_SESSION['profiling'])) { + if (isset($_SESSION['profiling']) && PMA_profilingSupported()) { $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;'); }