]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1851354: blocklist MySQL 8+, offer MariaDB
authorDave Miller <github@justdave.net>
Mon, 4 Sep 2023 05:02:02 +0000 (01:02 -0400)
committerDave Miller <github@justdave.net>
Sat, 9 Sep 2023 10:38:15 +0000 (06:38 -0400)
Bugzilla/Constants.pm
Bugzilla/DB.pm

index edaa8baa5b20b17f27d533ec028b578fc60ce6c2..1ed204cf880d8f36a6befbae0dfed3370501f005 100644 (file)
@@ -508,7 +508,11 @@ use constant INSTALLATION_MODE_NON_INTERACTIVE => 1;
 use constant DB_MODULE => {
     # MySQL 5.0.15 was the first production 5.0.x release.
     'mysql' => {db => 'Bugzilla::DB::Mysql', db_version => '5.0.15',
-                dbd => { 
+                db_blacklist => ['^[89]\.'],
+                # the following is a "human-readable" version to show in the
+                # release notes
+                db_blklst_str => '>= 8.0',
+                dbd => {
                     package => 'DBD-mysql',
                     module  => 'DBD::mysql',
                     # Disallow development versions
@@ -518,6 +522,28 @@ use constant DB_MODULE => {
                     version => '4.001',
                 },
                 name => 'MySQL'},
+
+    # MariaDB is a drop-in replacement for MySQL and works with Bugzilla
+    'mariadb' => {db => 'Bugzilla::DB::Mysql', db_version => '5.1',
+                  # MariaDB is indistinguishable from MySQL, but skipped 8 and
+                  # 9 so blacklist it anyway in case someone has the driver set
+                  # to mariadb but actually has MySQL.
+                  db_blacklist => ['^[89]\.'],
+                  # no string to show the user on the release notes though.
+                  dbd        => {
+                    package => 'DBD-mysql',
+                    module  => 'DBD::mysql',
+
+                    # Disallow development versions
+                    blacklist => ['_'],
+
+                    # For UTF-8 support. 4.001 makes sure that blobs aren't
+                    # marked as UTF-8.
+                    version => '4.001',
+                  },
+                  name => 'MariaDB'
+    },
+
     # Also see Bugzilla::DB::Pg::bz_check_server_version, which has special
     # code to require DBD::Pg 2.17.2 for PostgreSQL 9 and above.
     'pg'    => {db => 'Bugzilla::DB::Pg', db_version => '8.03.0000',
index 5bc83f9d6ab75dee945ecacdf9bfa759fa3b807f..af3672266ab6068273625714723ad11d492ab416 100644 (file)
@@ -204,17 +204,33 @@ sub bz_check_server_version {
     $self->disconnect;
 
     my $sql_want = $db->{db_version};
+    my $sql_dontwant = exists $db->{db_blacklist} ? $db->{db_blacklist} : [];
     my $version_ok = vers_cmp($sql_vers, $sql_want) > -1 ? 1 : 0;
+    my $blacklisted;
+    if ($version_ok) {
+        $blacklisted = grep($sql_vers =~ /$_/, @$sql_dontwant);
+        $version_ok = 0 if $blacklisted;
+    }
 
     my $sql_server = $db->{name};
     if ($output) {
         Bugzilla::Install::Requirements::_checking_for({
             package => $sql_server, wanted => $sql_want,
-            found   => $sql_vers, ok => $version_ok });
+            found   => $sql_vers, ok => $version_ok,
+            blacklisted => $blacklisted });
     }
 
     # Check what version of the database server is installed and let
     # the user know if the version is too old to be used with Bugzilla.
+    if ($blacklisted) {
+        die <<EOT;
+
+Your $sql_server v$sql_vers is blacklisted. Please check the
+release notes for details or try a different database engine
+or version.
+
+EOT
+    }
     if (!$version_ok) {
         die <<EOT;