]> 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:06:35 +0000 (01:06 -0400)
committerDave Miller <github@justdave.net>
Mon, 4 Sep 2023 05:06:35 +0000 (01:06 -0400)
Bugzilla/Constants.pm
Bugzilla/DB.pm

index 60ca7cc3413504ebe71ea3e8d254842ba2c38f1f..a74d910b3ad0cc89986a10118c06a2a5f1179c74 100644 (file)
@@ -471,7 +471,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
@@ -481,6 +485,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 248312e121c568769f2156c266801a803fe7eb90..93cb74242d8984e10809e375eaa0c262938ec81b 100644 (file)
@@ -200,17 +200,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;