]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1886359: fix PostgreSQL support on Harmony (#115)
authorDave Miller <justdave@bugzilla.org>
Sat, 30 Mar 2024 06:54:24 +0000 (02:54 -0400)
committerGitHub <noreply@github.com>
Sat, 30 Mar 2024 06:54:24 +0000 (02:54 -0400)
13 files changed:
.github/workflows/ci.yml
Bugzilla/Attachment/Storage/Base.pm
Bugzilla/Attachment/Storage/Database.pm
Bugzilla/DB.pm
Bugzilla/Install/DB.pm
RELEASE_BLOCKERS.md
docker-compose.test-pg.yml
docker-compose.test.yml
docker-compose.yml
docker/run-tests-in-docker.sh
extensions/FlagTypeComment/Extension.pm
extensions/PhabBugz/lib/Feed.pm
scripts/generate_conduit_data.pl

index 8ded772fb7a7bb1e0d0b24c894ec47c9cad9455a..88c3563b3a5138a15e16aac9a1a413ce822bf16f 100644 (file)
@@ -26,7 +26,7 @@ jobs:
 #      - name: Run webservice tests
 #        run: docker-compose -f docker-compose.test.yml run bugzilla6.test test_webservices
 
-  test_bugzilla6:
+  test_bugzilla6_mysql:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
@@ -37,3 +37,14 @@ jobs:
       - name: Run bmo specific tests
         run: docker-compose -f docker-compose.test.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t
 
+  test_bugzilla6_pg:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - name: Install docker-compose
+        run: sudo apt update && sudo apt install -y docker-compose
+      - name: Build the Docker images
+        run: docker compose -f docker-compose.test-pg.yml build
+      - name: Run bmo specific tests
+        run: docker-compose -f docker-compose.test-pg.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t
+
index 780aa2da280aa96b73f7692d49c39bbdc0eedb34..8df036c8d696df86a85a4380dc60ba0d14b2da6c 100644 (file)
@@ -22,9 +22,16 @@ has 'attach_id' => (
 
 sub set_class {
   my ($self) = @_;
-  Bugzilla->dbh->do(
-    "REPLACE INTO attachment_storage_class (id, storage_class) VALUES (?, ?)",
-    undef, $self->attach_id, $self->data_type);
+  if ($self->data_exists()) {
+    Bugzilla->dbh->do(
+      "UPDATE attachment_storage_class SET storage_class = ? WHERE id = ?",
+      undef, $self->data_type, $self->attach_id);
+  }
+  else {
+    Bugzilla->dbh->do(
+      "INSERT INTO attachment_storage_class (id, storage_class) VALUES (?, ?)",
+      undef, $self->attach_id, $self->data_type);
+  }
   return $self;
 }
 
index 22eaf762b48e1f99ac72f51fa59ae7ebda74f2dd..4d146cefc5d7c5cc9cf30120bf8b4036d4f864ce 100644 (file)
@@ -17,13 +17,24 @@ sub data_type { return 'database'; }
 sub set_data {
   my ($self, $data) = @_;
   my $dbh = Bugzilla->dbh;
-  my $sth
-    = $dbh->prepare(
-    "REPLACE INTO attach_data (id, thedata) VALUES (?, ?)"
-    );
-  $sth->bind_param(1, $self->attach_id);
-  $sth->bind_param(2, $data, $dbh->BLOB_TYPE);
-  $sth->execute();
+  if ($self->data_exists()) {
+    my $sth
+      = $dbh->prepare(
+      "UPDATE attach_data SET thedata = ? WHERE id = ?"
+      );
+    $sth->bind_param(1, $data, $dbh->BLOB_TYPE);
+    $sth->bind_param(2, $self->attach_id);
+    $sth->execute();
+  }
+  else {
+    my $sth
+      = $dbh->prepare(
+      "INSERT INTO attach_data (id, thedata) VALUES (?, ?)"
+      );
+    $sth->bind_param(1, $self->attach_id);
+    $sth->bind_param(2, $data, $dbh->BLOB_TYPE);
+    $sth->execute();
+  }
   return $self;
 }
 
index f5407f9f57bda75ca5655fc3c42690ca1d12585a..3e9d4cc0870f59d50f4ad5b64a288937ce264446 100644 (file)
@@ -251,6 +251,27 @@ sub bz_check_requirements {
   print "\n" if $output;
 }
 
+sub _bz_check_dbd {
+  my ($db, $output) = @_;
+
+  my $dbd = $db->{dbd};
+  unless (vers_cmp($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};
+    die <<EOT;
+
+For $sql_server, Bugzilla requires that perl's $dbd_mod $dbd_ver or later be
+installed. To install this module, run the following command (as $root):
+
+    $command
+
+EOT
+  }
+}
+
 sub bz_check_server_version {
   my ($self, $db, $output) = @_;
 
index dd5de66883926b686ae61f74022503eafc0c9b63..65ef9913aebc0734ed44181491d5ae68b4e66bfa 100644 (file)
@@ -4242,7 +4242,7 @@ sub _migrate_nicknames {
   my $dbh = Bugzilla->dbh;
   my $sth
     = $dbh->prepare(
-    'SELECT userid FROM profiles WHERE realname LIKE "%:%" AND is_enabled = 1 AND NOT nickname'
+    "SELECT userid FROM profiles WHERE realname LIKE '%:%' AND is_enabled = 1 AND nickname = ''"
     );
   $sth->execute();
   while (my ($user_id) = $sth->fetchrow_array) {
index 79de51634665df81789d8ac11408119fec7f4f87..a14c3cb6aa90f2c3d8a0b104c63e8689b1499bc9 100644 (file)
@@ -47,6 +47,8 @@ they used for their local customizations instead of in the actual database
 abstraction modules. This code needs to be migrated back to the database
 abstraction modules so their extension can be disposed of.
 
+**[COMPLETED]**
+
 # Sensible, Default Logging Configuration
 
 Bugzilla::Logging controls how the application logs. It has support for
index 8a66a7904bbfda6fdabc84d1ea2c5e78308422d2..cd6deee5e63cbebad4c8a614f3e52e1ef4dd210b 100644 (file)
@@ -16,7 +16,7 @@ services:
     environment:
       - 'BMO_inbound_proxies=*'
       - BMO_db_driver=pg
-      - BMO_db_host=bugzilla6.db
+      - BMO_db_host=bugzilla6.pgsql9
       - BMO_db_name=bugs
       - BMO_db_pass=bugs
       - BMO_db_user=bugs
@@ -27,8 +27,8 @@ services:
       - BMO_urlbase=AUTOMATIC
       - BUGZILLA_ALLOW_INSECURE_HTTP=1
       - BZ_ANSWERS_FILE=/app/conf/checksetup_answers.txt
-      - BZ_QA_ANSWERS_FILE=/app/.circleci/checksetup_answers.txt
-      - BZ_QA_CONF_FILE=/app/.circleci/selenium_test.conf
+      - BZ_QA_ANSWERS_FILE=/app/.github/checksetup_answers.txt
+      - BZ_QA_CONF_FILE=/app/.github/selenium_test.conf
       - BZ_QA_CONFIG=1
       - LOCALCONFIG_ENV=1
       - LOG4PERL_CONFIG_FILE=log4perl-test.conf
@@ -38,11 +38,11 @@ services:
       - TWD_HOST=selenium
       - TWD_PORT=4444
     depends_on:
-      - bugzilla6.db
+      - bugzilla6.pgsql9
       - memcached
       - selenium
 
-  bugzilla6.db:
+  bugzilla6.pgsql9:
     image: postgres:9.0
     tmpfs:
       - /tmp
index abe7a3b67c7495b290e26e19697e9e2567f68dab..5a6b06a4c3a01fb3fd013ee811307214571d58cc 100644 (file)
@@ -15,7 +15,7 @@ services:
       - /run
     environment:
       - 'BMO_inbound_proxies=*'
-      - BMO_db_host=bugzilla6.db
+      - BMO_db_host=bugzilla6.mysql8
       - BMO_db_name=bugs
       - BMO_db_pass=bugs
       - BMO_db_user=bugs
@@ -38,11 +38,11 @@ services:
       - TWD_HOST=selenium
       - TWD_PORT=4444
     depends_on:
-      - bugzilla6.db
+      - bugzilla6.mysql8
       - memcached
       - selenium
 
-  bugzilla6.db:
+  bugzilla6.mysql8:
     image: mysql:8
     tmpfs:
       - /tmp
index e8b331305ede647a69f0e672f6de26e467638f3d..1e2fa04e4ee5c4b0cfe8cd543b5cb88c028da61a 100644 (file)
@@ -18,7 +18,7 @@ services:
       - /run
     environment: &bz_env
       - 'BMO_inbound_proxies=*'
-      - BMO_db_host=bugzilla6.db
+      - BMO_db_host=bugzilla6.mysql8
       - BMO_db_name=bugs
       - BMO_db_pass=bugs
       - BMO_db_user=bugs
@@ -36,7 +36,7 @@ services:
       - MOJO_LISTEN=http://*:8000
       - PORT=8000
     depends_on:
-      - bugzilla6.db
+      - bugzilla6.mysql8
       - memcached
 #      - tinyproxy
     ports:
@@ -53,7 +53,7 @@ services:
 #    environment: *bz_env
 #    restart: always
 #    depends_on:
-#      - bugzilla6.db
+#      - bugzilla6.mysql8
 #      - memcached
 
 #  bugzilla6.feed:
@@ -72,7 +72,7 @@ services:
 #    environment: *bz_env
 #    restart: always
 #    depends_on:
-#      - bugzilla6.db
+#      - bugzilla6.mysql8
 #      - memcached
 
 #  bugzilla6.pushd:
@@ -91,10 +91,10 @@ services:
 #    environment: *bz_env
 #    restart: always
 #    depends_on:
-#      - bugzilla6.db
+#      - bugzilla6.mysql8
 #      - memcached
 
-  bugzilla6.db:
+  bugzilla6.mysql8:
     build:
       context: .
       dockerfile: Dockerfile.mysql8
index 6bb4d75de9ca53658f2f58e531539f9fbf58c9aa..fd76880e628af4aafa91179479be4f89052cd085 100644 (file)
@@ -51,10 +51,14 @@ export DOCKER_CLI_HINTS=false
 export CI=""
 export CIRCLE_SHA1=""
 export CIRCLE_BUILD_URL=""
-$DOCKER compose -f docker-compose.test.yml build
+DOCKER_COMPOSE_FILE=docker-compose.test.yml
+if [ "$1" == "pg" ]; then
+    DOCKER_COMPOSE_FILE=docker-compose.test-pg.yml
+fi
+$DOCKER compose -f $DOCKER_COMPOSE_FILE build
 if [ $? == 0 ]; then
-    $DOCKER compose -f docker-compose.test.yml run --rm --name bugzilla6.test bugzilla6.test test_bmo -q -f t/bmo/*.t
-    $DOCKER compose -f docker-compose.test.yml stop
+    $DOCKER compose -f $DOCKER_COMPOSE_FILE run --rm --name bugzilla6.test bugzilla6.test test_bmo -q -f t/bmo/*.t
+    $DOCKER compose -f $DOCKER_COMPOSE_FILE down
 else
     echo "docker compose build failed."
 fi
index 4a7e1bb117076abdded252adf9f51d9bb96538aa..fabbb9bee8d32c3a34c2a8ca70308332c263f302 100644 (file)
@@ -42,7 +42,7 @@ sub db_schema_abstract_schema {
   $args->{'schema'}->{'flagtype_comments'} = {
     FIELDS => [
       type_id => {
-        TYPE       => 'SMALLINT(6)',
+        TYPE       => 'INT2',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
index a3290fbbe6b27a091e0d89d8b6161d8713389bb2..8d57c245fe4cff4581f9086f5f6c3290c6a036b1 100644 (file)
@@ -740,8 +740,15 @@ sub save_last_id {
   # Store the largest last key so we can start from there in the next session
   my $type_full = $type . "_last_id";
   TRACE("UPDATING " . uc($type_full) . ": $last_id");
-  Bugzilla->dbh->do("REPLACE INTO phabbugz (name, value) VALUES (?, ?)",
-    undef, $type_full, $last_id);
+  if (Bugzilla->dbh->selectrow_array("SELECT 1 FROM phabbugz WHERE name = ?",
+        undef, $type_full)) {
+    Bugzilla->dbh->do("UPDATE phabbugz SET value = ? WHERE name = ?",
+      undef, $last_id, $type_full);
+  }
+  else {
+    Bugzilla->dbh->do("INSERT INTO phabbugz (name, value) VALUES (?, ?)",
+      undef, $type_full, $last_id);
+  }
 }
 
 sub get_group_members {
index 441b97b40b11b6d1570c1d1cbf0585c5395105d2..27acc3fb861f6914944c890cdcdae8e9d8cfe57f 100755 (executable)
@@ -187,10 +187,19 @@ my $oauth_secret = $ENV{PHABRICATOR_OAUTH_SECRET} || '';
 if ($oauth_id && $oauth_secret) {
   print "creating phabricator oauth2 client...\n";
 
-  $dbh->do(
-    'REPLACE INTO oauth2_client (client_id, description, secret) VALUES (?, \'Phabricator\', ?)',
-    undef, $oauth_id, $oauth_secret
-  );
+  if ($dbh->selectrow_array("SELECT 1 FROM oauth2_client WHERE client_id = ?",
+        undef, $oauth_id)) {
+    $dbh->do(
+      "UPDATE oauth2_client SET description = 'Phabricator', secret = ? WHERE client_id = ?",
+      undef, $oauth_secret, $oauth_id
+    );
+  }
+  else {
+    $dbh->do(
+      'INSERT INTO oauth2_client (client_id, description, secret) VALUES (?, \'Phabricator\', ?)',
+      undef, $oauth_id, $oauth_secret
+    );
+  }
 
   my $client_data
     = $dbh->selectrow_hashref('SELECT * FROM oauth2_client WHERE client_id = ?',
@@ -199,8 +208,17 @@ if ($oauth_id && $oauth_secret) {
   my $scope_id = $dbh->selectrow_array(
     'SELECT id FROM oauth2_scope WHERE name = \'user:read\'', undef);
 
-  $dbh->do('REPLACE INTO oauth2_client_scope (client_id, scope_id) VALUES (?, ?)',
-    undef, $client_data->{id}, $scope_id);
+  if ($dbh->selectrow_array("SELECT 1 FROM oauth2_client_scope WHERE client_id = ?",
+      undef, $client_data->{id})) {
+    $dbh->do("UPDATE oauth2_client_scope SET scope_id = ? WHERE client_id = ?",
+      undef, $scope_id, $client_data->{id}
+    );
+  }
+  else {
+    $dbh->do('INSERT INTO oauth2_client_scope (client_id, scope_id) VALUES (?, ?)',
+      undef, $client_data->{id}, $scope_id
+    );
+  }
 }
 
 print "installation and configuration complete!\n";