From cd4efcf95f7ccbb853503bf6b7953a56b423ce91 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 28 Aug 2024 16:34:57 +1200 Subject: [PATCH] DEP Remove support for MySQL 5 --- _register_database.php | 2 +- src/Dev/Install/MySQLDatabaseConfigurationHelper.php | 6 +++--- src/ORM/Connect/DBSchemaManager.php | 4 +--- src/ORM/Connect/MySQLDatabase.php | 5 ++--- src/ORM/FieldType/DBField.php | 2 +- src/ORM/Queries/SQLDelete.php | 2 +- tests/php/ORM/SQLSelectTest.php | 2 +- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/_register_database.php b/_register_database.php index 35d09b53d6d..91f5a85f8ef 100644 --- a/_register_database.php +++ b/_register_database.php @@ -9,7 +9,7 @@ [ 'class' => 'MySQLDatabase', 'module' => 'framework', - 'title' => 'MySQL 5.0+ (using MySQLi)', + 'title' => 'MySQL 8.0+ (using MySQLi)', 'helperPath' => __DIR__ . '/src/Dev/Install/MySQLDatabaseConfigurationHelper.php', 'helperClass' => MySQLDatabaseConfigurationHelper::class, 'supported' => class_exists('MySQLi'), diff --git a/src/Dev/Install/MySQLDatabaseConfigurationHelper.php b/src/Dev/Install/MySQLDatabaseConfigurationHelper.php index 21fff8627e9..3d94a289dba 100644 --- a/src/Dev/Install/MySQLDatabaseConfigurationHelper.php +++ b/src/Dev/Install/MySQLDatabaseConfigurationHelper.php @@ -135,7 +135,7 @@ public function requireDatabaseVersion($databaseConfig) if ($version) { $success = version_compare($version ?? '', '5.0', '>='); if (!$success) { - $error = "Your MySQL server version is $version. It's recommended you use at least MySQL 5.0."; + $error = "Your MySQL server version is $version. It's recommended you use at least MySQL 8.0."; } } else { $error = "Could not determine your MySQL version."; @@ -178,7 +178,7 @@ public function checkValidDatabaseName($database) } // Restricted to characters in the ASCII and Extended ASCII range - // @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html + // @see https://dev.mysql.com/doc/refman/8.4/en/identifiers.html return preg_match('/^[\x{0001}-\x{FFFF}]+$/u', $database ?? ''); } @@ -199,7 +199,7 @@ public function checkDatabasePermissionGrant($database, $permission, $grant) } // Escape all valid database patterns (permission must exist on all tables) - $sqlDatabase = addcslashes($database ?? '', '_%'); // See http://dev.mysql.com/doc/refman/5.7/en/string-literals.html + $sqlDatabase = addcslashes($database ?? '', '_%'); // https://dev.mysql.com/doc/refman/8.4/en/string-literals.html $dbPattern = sprintf( '((%s)|(%s)|(%s)|(%s))', preg_quote("\"$sqlDatabase\".*"), // Regexp escape sql-escaped db identifier diff --git a/src/ORM/Connect/DBSchemaManager.php b/src/ORM/Connect/DBSchemaManager.php index 449333e4a67..c889bb66918 100644 --- a/src/ORM/Connect/DBSchemaManager.php +++ b/src/ORM/Connect/DBSchemaManager.php @@ -601,7 +601,7 @@ protected function determineIndexType($spec) * Some indexes may be arrays, such as fulltext and unique indexes, and this allows database-specific * arrays to be created. See {@link requireTable()} for details on the index format. * - * @see http://dev.mysql.com/doc/refman/5.0/en/create-index.html + * @see https://dev.mysql.com/doc/refman/8.4/en/create-index.html * @see parseIndexSpec() for approximate inverse * * @param string|array $indexSpec @@ -679,8 +679,6 @@ public function requireField($table, $field, $spec) $spec = $this->{$spec['type']}($spec['parts'], true); } - // Collations didn't come in until MySQL 4.1. Anything earlier will throw a syntax error if you try and use - // collations. if (!$this->database->supportsCollations()) { $spec = preg_replace('/ *character set [^ ]+( collate [^ ]+)?( |$)/', '\\2', $spec ?? ''); } diff --git a/src/ORM/Connect/MySQLDatabase.php b/src/ORM/Connect/MySQLDatabase.php index dd9440096bb..0935300f22a 100644 --- a/src/ORM/Connect/MySQLDatabase.php +++ b/src/ORM/Connect/MySQLDatabase.php @@ -529,9 +529,8 @@ public function getLock($name, $timeout = 5) { $id = $this->getLockIdentifier($name); - // MySQL 5.7.4 and below auto-releases existing locks on subsequent GET_LOCK() calls. - // MySQL 5.7.5 and newer allow multiple locks per sessions even with the same name. - // https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock + // MySQL 8.0.0 and newer allow multiple locks per sessions even with the same name. + // https://dev.mysql.com/doc/refman/8.4/en/locking-functions.html#function_get-lock return (bool) $this->query(sprintf("SELECT GET_LOCK('%s', %d)", $id, $timeout))->value(); } diff --git a/src/ORM/FieldType/DBField.php b/src/ORM/FieldType/DBField.php index 0053057e4ef..97900eca8fd 100644 --- a/src/ORM/FieldType/DBField.php +++ b/src/ORM/FieldType/DBField.php @@ -31,7 +31,7 @@ * Subclass Example * * The class is easy to overload with custom types, e.g. the MySQL "BLOB" type - * (http://dev.mysql.com/doc/refman/5.0/en/blob.html). + * (https://dev.mysql.com/doc/refman/8.4/en/blob.html). * * * class Blob extends DBField { diff --git a/src/ORM/Queries/SQLDelete.php b/src/ORM/Queries/SQLDelete.php index edd212537b0..72599f1c1ad 100644 --- a/src/ORM/Queries/SQLDelete.php +++ b/src/ORM/Queries/SQLDelete.php @@ -15,7 +15,7 @@ class SQLDelete extends SQLConditionalExpression * List of tables to limit the delete to, if multiple tables * are specified in the condition clause * - * @see http://dev.mysql.com/doc/refman/5.0/en/delete.html + * @see https://dev.mysql.com/doc/refman/8.4/en/delete.html * * @var array */ diff --git a/tests/php/ORM/SQLSelectTest.php b/tests/php/ORM/SQLSelectTest.php index 73f3a586fe5..d915a676c29 100755 --- a/tests/php/ORM/SQLSelectTest.php +++ b/tests/php/ORM/SQLSelectTest.php @@ -957,7 +957,7 @@ public function testBaseTableAliases() public function provideWith() { // Each of these examples shows it working with aliased implicit columns, and with explicit CTE columns. - // Most of these examples are derived from https://dev.mysql.com/doc/refman/8.0/en/with.html + // Most of these examples are derived from https://dev.mysql.com/doc/refman/8.4/en/with.html return [ // Just a CTE, no union 'basic CTE with aliased columns' => [