diff --git a/db_operations.php b/db_operations.php index a65d798aba..010fa0496f 100644 --- a/db_operations.php +++ b/db_operations.php @@ -106,7 +106,7 @@ if (strlen($GLOBALS['db']) > 0 } unset($sqlConstratints); - if (PMA_MYSQL_INT_VERSION >= 50100) { + if ($GLOBALS['dbi']->getVersion() >= 50100) { // here DELIMITER is not used because it's not part of the // language; each statement is sent one by one diff --git a/libraries/classes/Advisor.php b/libraries/classes/Advisor.php index 80791aee0c..bf0f757b9c 100644 --- a/libraries/classes/Advisor.php +++ b/libraries/classes/Advisor.php @@ -99,7 +99,7 @@ class Advisor ); /* Some global variables for advisor */ $this->globals = array( - 'PMA_MYSQL_INT_VERSION' => PMA_MYSQL_INT_VERSION, + 'PMA_MYSQL_INT_VERSION' => $GLOBALS['dbi']->getVersion(), ); } diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 8a4a1730be..4a6b3bf6b4 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -1409,10 +1409,6 @@ class DatabaseInterface } } - if (! defined('PMA_MYSQL_INT_VERSION')) { - define('PMA_MYSQL_INT_VERSION', $this->_version_int); - } - if ($this->_version_int > 50503) { $default_charset = 'utf8mb4'; $default_collation = 'utf8mb4_general_ci'; diff --git a/libraries/classes/Partition.php b/libraries/classes/Partition.php index 7f721199eb..2f0a2afe1e 100644 --- a/libraries/classes/Partition.php +++ b/libraries/classes/Partition.php @@ -243,7 +243,7 @@ class Partition extends SubPartition static $already_checked = false; if (! $already_checked) { - if (PMA_MYSQL_INT_VERSION < 50600) { + if ($GLOBALS['dbi']->getVersion() < 50600) { if ($GLOBALS['dbi']->fetchValue( "SELECT @@have_partitioning;" )) { diff --git a/libraries/classes/StorageEngine.php b/libraries/classes/StorageEngine.php index f1e1dcbe46..3513a7e77a 100644 --- a/libraries/classes/StorageEngine.php +++ b/libraries/classes/StorageEngine.php @@ -108,7 +108,7 @@ class StorageEngine if (null == $storage_engines) { $storage_engines = $GLOBALS['dbi']->fetchResult('SHOW STORAGE ENGINES', 'Engine'); - if (PMA_MYSQL_INT_VERSION >= 50708) { + if ($GLOBALS['dbi']->getVersion() >= 50708) { $disabled = Util::cacheGet( 'disabled_storage_engines', function () { diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index e82f6c2fc6..334479a977 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -2512,7 +2512,7 @@ class Table { $serverType = Util::getServerType(); if ($serverType == 'MySQL' - && PMA_MYSQL_INT_VERSION > 50705 + && $GLOBALS['dbi']->getVersion() > 50705 && ! $GLOBALS['cfg']['Server']['DisableIS'] ) { $sql diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index acd272fcfa..fcca577f08 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -362,12 +362,13 @@ class Util } $mysql = '5.5'; $lang = 'en'; - if (defined('PMA_MYSQL_INT_VERSION')) { - if (PMA_MYSQL_INT_VERSION >= 50700) { + if (isset($GLOBALS['dbi'])) { + $serverVersion = $GLOBALS['dbi']->getVersion(); + if ($serverVersion >= 50700) { $mysql = '5.7'; - } elseif (PMA_MYSQL_INT_VERSION >= 50600) { + } elseif ($serverVersion >= 50600) { $mysql = '5.6'; - } elseif (PMA_MYSQL_INT_VERSION >= 50500) { + } elseif ($serverVersion >= 50500) { $mysql = '5.5'; } } @@ -1273,8 +1274,7 @@ class Util // 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') - && $GLOBALS['dbi']->fetchValue("SELECT @@have_profiling") + if ($GLOBALS['dbi']->fetchValue("SELECT @@have_profiling") ) { self::cacheSet('profiling_supported', true); } else { @@ -2550,7 +2550,7 @@ class Util $functionality, $component, $minimum_version, $bugref ) { $ext_but_html = ''; - if (($component == 'mysql') && (PMA_MYSQL_INT_VERSION < $minimum_version)) { + if (($component == 'mysql') && ($GLOBALS['dbi']->getVersion() < $minimum_version)) { $ext_but_html .= self::showHint( sprintf( __('The %s functionality is affected by a known bug, see %s'), @@ -3666,7 +3666,7 @@ class Util $funcs[] = array('display' => '--------'); } - if (PMA_MYSQL_INT_VERSION < 50601) { + if ($GLOBALS['dbi']->getVersion() < 50601) { $funcs['Crosses'] = array('params' => 2, 'type' => 'int'); $funcs['Contains'] = array('params' => 2, 'type' => 'int'); $funcs['Disjoint'] = array('params' => 2, 'type' => 'int'); @@ -4346,8 +4346,9 @@ class Util public static function isVirtualColumnsSupported() { $serverType = self::getServerType(); - return $serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50705 - || ($serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION >= 50200); + $serverVersion = $GLOBALS['dbi']->getVersion(); + return $serverType == 'MySQL' && $serverVersion >= 50705 + || ($serverType == 'MariaDB' && $serverVersion >= 50200); } /** diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 34d5aaf997..97543b20bb 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -785,7 +785,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { /* Log success */ Logging::logUser($cfg['Server']['user']); - if (PMA_MYSQL_INT_VERSION < $cfg['MysqlMinVersion']['internal']) { + if ($GLOBALS['dbi']->getVersion() < $cfg['MysqlMinVersion']['internal']) { Core::fatalError( __('You should upgrade to %s %s or later.'), array('MySQL', $cfg['MysqlMinVersion']['human']) @@ -798,7 +798,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { $GLOBALS['PMA_Types'] = new TypesMySQL(); // Loads closest context to this version. - PhpMyAdmin\SqlParser\Context::loadClosest('MySql' . PMA_MYSQL_INT_VERSION); + PhpMyAdmin\SqlParser\Context::loadClosest('MySql' . $GLOBALS['dbi']->getVersion()); // Sets the default delimiter (if specified). if (!empty($_REQUEST['sql_delimiter'])) { diff --git a/libraries/display_change_password.lib.php b/libraries/display_change_password.lib.php index d8eb860246..266019a118 100644 --- a/libraries/display_change_password.lib.php +++ b/libraries/display_change_password.lib.php @@ -80,6 +80,7 @@ function PMA_getHtmlForChangePassword($mode, $username, $hostname) . ''; $serverType = PhpMyAdmin\Util::getServerType(); + $serverVersion = $GLOBALS['dbi']->getVersion(); $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin( 'change', $username, @@ -88,14 +89,14 @@ function PMA_getHtmlForChangePassword($mode, $username, $hostname) $is_superuser = $GLOBALS['dbi']->isSuperuser(); if (($serverType == 'MySQL' - && PMA_MYSQL_INT_VERSION >= 50507) + && $serverVersion >= 50507) || ($serverType == 'MariaDB' - && PMA_MYSQL_INT_VERSION >= 50200) + && $serverVersion >= 50200) ) { // Provide this option only for 5.7.6+ // OR for privileged users in 5.5.7+ if (($serverType == 'MySQL' - && PMA_MYSQL_INT_VERSION >= 50706) + && $serverVersion >= 50706) || ($is_superuser && $mode == 'edit_other') ) { $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown( diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index 93eef582f7..83aa1d83cb 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -960,7 +960,7 @@ function PMA_getHtmlForRenameTable() */ function PMA_getHtmlForTableComments($current_value) { - $commentLength = PMA_MYSQL_INT_VERSION >= 50503 ? 2048 : 60; + $commentLength = $GLOBALS['dbi']->getVersion() >= 50503 ? 2048 : 60; $html_output = '' . __('Table comments') . '' . ' 50503) { + if ($set_names == 'utf8' && $GLOBALS['dbi']->getVersion() > 50503) { $set_names = 'utf8mb4'; } $head .= $crlf diff --git a/libraries/tbl_columns_definition_form.inc.php b/libraries/tbl_columns_definition_form.inc.php index 71f9a5f093..26d382f3bf 100644 --- a/libraries/tbl_columns_definition_form.inc.php +++ b/libraries/tbl_columns_definition_form.inc.php @@ -122,7 +122,7 @@ $foreigners = PMA_getForeigners($db, $table, '', 'foreign'); $child_references = null; // From MySQL 5.6.6 onwards columns with foreign keys can be renamed. // Hence, no need to get child references -if (PMA_MYSQL_INT_VERSION < 50606) { +if ($GLOBALS['dbi']->getVersion() < 50606) { $child_references = PMA_getChildReferences($db, $table); } @@ -284,7 +284,7 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) { // MySQL version from 5.6.6 allow renaming columns with foreign keys if (isset($columnMeta['Field']) && isset($form_params['table']) - && PMA_MYSQL_INT_VERSION < 50606 + && $GLOBALS['dbi']->getVersion() < 50606 ) { $columnMeta['column_status'] = PMA_checkChildForeignReferences( $form_params['db'], diff --git a/templates/columns_definitions/column_comment.phtml b/templates/columns_definitions/column_comment.phtml index 3233c4e007..c11f649171 100644 --- a/templates/columns_definitions/column_comment.phtml +++ b/templates/columns_definitions/column_comment.phtml @@ -2,9 +2,9 @@ type="text" name="field_comments[]" size="12" - maxlength="= 50503 ? 1024 : 255; ?>" + maxlength="getVersion() >= 50503 ? 1024 : 255; ?>" value="" - class="textfield" /> \ No newline at end of file + class="textfield" /> diff --git a/templates/table/structure/display_structure.phtml b/templates/table/structure/display_structure.phtml index 997457b67a..cde237768c 100644 --- a/templates/table/structure/display_structure.phtml +++ b/templates/table/structure/display_structure.phtml @@ -115,7 +115,7 @@ $rownum = 0; ?> 'is_in_central_columns' => in_array($row['Field'], $central_list) ? true : false, 'central_columns_work' => $GLOBALS['cfgRelation']['centralcolumnswork'], 'table' => $GLOBALS['table'], - 'mysql_int_version' => PMA_MYSQL_INT_VERSION + 'mysql_int_version' => $GLOBALS['dbi']->getVersion() ) ); ?> diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php index 228259698a..9cdce458f9 100644 --- a/test/bootstrap-dist.php +++ b/test/bootstrap-dist.php @@ -27,7 +27,6 @@ set_include_path( // Setting constants for testing define('PHPMYADMIN', 1); define('TESTSUITE', 1); -define('PMA_MYSQL_INT_VERSION', 55000); // Selenium tests setup $test_defaults = array( diff --git a/test/classes/plugin/auth/AuthenticationConfigTest.php b/test/classes/plugin/auth/AuthenticationConfigTest.php index 5feb64d6b6..841c535109 100644 --- a/test/classes/plugin/auth/AuthenticationConfigTest.php +++ b/test/classes/plugin/auth/AuthenticationConfigTest.php @@ -115,7 +115,7 @@ class AuthenticationConfigTest extends PMATestCase $this->assertContains( 'MySQL said: ' . 'Documentation',