]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 603127: Make checksetup.pl require DBD::Pg 2.17.2 when using Pg 9.0 or
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 14 Feb 2011 20:01:56 +0000 (12:01 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 14 Feb 2011 20:01:56 +0000 (12:01 -0800)
later.
r=dkl, a=mkanat

Bugzilla/Constants.pm
Bugzilla/DB.pm
Bugzilla/DB/Mysql.pm
Bugzilla/DB/Pg.pm
skins/standard/attachment.css

index 5125b85705b575c73d271fcd84138888fe149c61..3422018013d02de92d87a7f9aafdeb7367c287f8 100644 (file)
@@ -486,6 +486,8 @@ use constant DB_MODULE => {
                     version => '4.00',
                 },
                 name => 'MySQL'},
+    # 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.00.0000',
                 dbd => {
                     package => 'DBD-Pg',
index 0c4de1c4ac0d99f67075df248efe5e42e99c1f9d..cda668b91ab48e1cfa14a3da78aa3a8aa20ef1a2 100644 (file)
@@ -136,26 +136,41 @@ sub bz_check_requirements {
 
     my $lc = Bugzilla->localconfig;
     my $db = DB_MODULE->{lc($lc->{db_driver})};
+
     # Only certain values are allowed for $db_driver.
     if (!defined $db) {
         die "$lc->{db_driver} is not a valid choice for \$db_driver in"
             . bz_locations()->{'localconfig'};
     }
 
-    die("It is not safe to run Bugzilla inside the 'mysql' database.\n"
-        . "Please pick a different value for \$db_name in localconfig.")
-        if $lc->{db_name} eq 'mysql';
-
     # Check the existence and version of the DBD that we need.
-    my $dbd        = $db->{dbd};
-    my $sql_server = $db->{name};
-    my $sql_want   = $db->{db_version};
+    my $dbd = $db->{dbd};
+    _bz_check_dbd($db, $output);
+
+    # We don't try to connect to the actual database if $db_check is
+    # disabled.
+    unless ($lc->{db_check}) {
+        print "\n" if $output;
+        return;
+    }
+
+    # And now check the version of the database server itself.
+    my $dbh = _get_no_db_connection();
+    $dbh->bz_check_server_version($db, $output);
+
+    print "\n" if $output;
+}
+
+sub _bz_check_dbd {
+    my ($db, $output) = @_;
+
+    my $dbd = $db->{dbd};
     unless (have_vers($dbd, $output)) {
+        my $sql_server = $db->{name};
         my $command = install_command($dbd);
         my $root    = ROOT_USER;
         my $dbd_mod = $dbd->{module};
         my $dbd_ver = $dbd->{version};
-        my $version = $dbd_ver ? " $dbd_ver or higher" : '';
         die <<EOT;
 
 For $sql_server, Bugzilla requires that perl's $dbd_mod $dbd_ver or later be
@@ -165,21 +180,18 @@ installed. To install this module, run the following command (as $root):
 
 EOT
     }
+}
 
-    # We don't try to connect to the actual database if $db_check is
-    # disabled.
-    unless ($lc->{db_check}) {
-        print "\n" if $output;
-        return;
-    }
-
-    # And now check the version of the database server itself.
-    my $dbh = _get_no_db_connection();
+sub bz_check_server_version {
+    my ($self, $db, $output) = @_;
 
-    my $sql_vers = $dbh->bz_server_version;
-    $dbh->disconnect;
+    my $sql_vers = $self->bz_server_version;
+    $self->disconnect;
 
+    my $sql_want = $db->{db_version};
     my $version_ok = vers_cmp($sql_vers, $sql_want) > -1 ? 1 : 0;
+
+    my $sql_server = $db->{name};
     if ($output) {
         Bugzilla::Install::Requirements::_checking_for({
             package => $sql_server, wanted => $sql_want,
@@ -198,7 +210,8 @@ newer version.
 EOT
     }
 
-    print "\n" if $output;
+    # This is used by subclasses.
+    return $sql_vers;
 }
 
 # Note that this function requires that localconfig exist and
index 7f3eb2ef8eeede28529a17dc8b068df1b7a76901..ffdaf32c0e85c03073ed4ab3292776acb317e737 100644 (file)
@@ -287,6 +287,18 @@ sub _bz_get_initial_schema {
 # Database Setup
 #####################################################################
 
+sub bz_check_server_version {
+    my $self = shift;
+
+    my $lc = Bugzilla->localconfig;
+    if (lc(Bugzilla->localconfig->{db_name}) eq 'mysql') {
+        die "It is not safe to run Bugzilla inside a database named 'mysql'.\n"
+            . " Please pick a different value for \$db_name in localconfig.\n";
+    }
+
+    $self->SUPER::bz_check_server_version(@_);
+}
+
 sub bz_setup_database {
     my ($self) = @_;
 
index 88e503be52567720d24a9958cefabf823873fecd..2f42064e8ad6d61a0ed4753f32ae070189fbe5e9 100644 (file)
@@ -211,6 +211,19 @@ sub bz_explain {
 # Custom Database Setup
 #####################################################################
 
+sub bz_check_server_version {
+    my $self = shift;
+    my ($db) = @_;
+    my $server_version = $self->SUPER::bz_check_server_version(@_);
+    my ($major_version) = $server_version =~ /^(\d+)/;
+    # Pg 9 requires DBD::Pg 2.17.2 in order to properly read bytea values.
+    if ($major_version >= 9) {
+        local $db->{dbd}->{version} = '2.17.2';
+        local $db->{name} = $db->{name} . ' 9+';
+        Bugzilla::DB::_bz_check_dbd(@_);
+    }
+}
+
 sub bz_setup_database {
     my $self = shift;
     $self->SUPER::bz_setup_database(@_);
index dbf136730c1965c87a7f43e338776d9e613eb250..aa0af37f387b31fe9fafa4c7f4b197c240781f98 100644 (file)
@@ -162,7 +162,7 @@ table.attachment_info td {
 }
 
 #attachment_information_read_only .details {
-    font-family: monospace;
+    font-size: 90%;
 }
 
 #attachment_info.read #attachment_information_edit {
@@ -239,4 +239,4 @@ div#update_container {
 
 .no_javascript .bz_hide, .no_javascript .bz_edit {
     display: none;
-}
\ No newline at end of file
+}