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 35d09b53d..91f5a85f8 100644 --- a/_register_database.php +++ b/_register_database.php @@ -9,7 +9,7 @@ DatabaseAdapterRegistry::register( [ '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 21fff8627..3d94a289d 100644 --- a/src/Dev/Install/MySQLDatabaseConfigurationHelper.php +++ b/src/Dev/Install/MySQLDatabaseConfigurationHelper.php @@ -135,7 +135,7 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper 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 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper } // 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 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper } // 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 449333e4a..c889bb669 100644 --- a/src/ORM/Connect/DBSchemaManager.php +++ b/src/ORM/Connect/DBSchemaManager.php @@ -601,7 +601,7 @@ abstract class DBSchemaManager * 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 @@ abstract class DBSchemaManager $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 dd9440096..0935300f2 100644 --- a/src/ORM/Connect/MySQLDatabase.php +++ b/src/ORM/Connect/MySQLDatabase.php @@ -529,9 +529,8 @@ class MySQLDatabase extends Database implements TransactionManager { $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 0053057e4..97900eca8 100644 --- a/src/ORM/FieldType/DBField.php +++ b/src/ORM/FieldType/DBField.php @@ -31,7 +31,7 @@ use SilverStripe\View\ViewableData; * 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 edd212537..72599f1c1 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 73f3a586f..d915a676c 100755 --- a/tests/php/ORM/SQLSelectTest.php +++ b/tests/php/ORM/SQLSelectTest.php @@ -957,7 +957,7 @@ class SQLSelectTest extends SapphireTest 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' => [