diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ded772fb7..88c3563b3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 + diff --git a/Bugzilla/Attachment/Storage/Base.pm b/Bugzilla/Attachment/Storage/Base.pm index 780aa2da28..8df036c8d6 100644 --- a/Bugzilla/Attachment/Storage/Base.pm +++ b/Bugzilla/Attachment/Storage/Base.pm @@ -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; } diff --git a/Bugzilla/Attachment/Storage/Database.pm b/Bugzilla/Attachment/Storage/Database.pm index 22eaf762b4..4d146cefc5 100644 --- a/Bugzilla/Attachment/Storage/Database.pm +++ b/Bugzilla/Attachment/Storage/Database.pm @@ -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; } diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index f5407f9f57..3e9d4cc087 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -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 <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) { diff --git a/RELEASE_BLOCKERS.md b/RELEASE_BLOCKERS.md index 79de516346..a14c3cb6aa 100644 --- a/RELEASE_BLOCKERS.md +++ b/RELEASE_BLOCKERS.md @@ -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 diff --git a/docker-compose.test-pg.yml b/docker-compose.test-pg.yml index 8a66a7904b..cd6deee5e6 100644 --- a/docker-compose.test-pg.yml +++ b/docker-compose.test-pg.yml @@ -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 diff --git a/docker-compose.test.yml b/docker-compose.test.yml index abe7a3b67c..5a6b06a4c3 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index e8b331305e..1e2fa04e4e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docker/run-tests-in-docker.sh b/docker/run-tests-in-docker.sh index 6bb4d75de9..fd76880e62 100644 --- a/docker/run-tests-in-docker.sh +++ b/docker/run-tests-in-docker.sh @@ -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 diff --git a/extensions/FlagTypeComment/Extension.pm b/extensions/FlagTypeComment/Extension.pm index 4a7e1bb117..fabbb9bee8 100644 --- a/extensions/FlagTypeComment/Extension.pm +++ b/extensions/FlagTypeComment/Extension.pm @@ -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'} }, diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index a3290fbbe6..8d57c245fe 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -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 { diff --git a/scripts/generate_conduit_data.pl b/scripts/generate_conduit_data.pl index 441b97b40b..27acc3fb86 100755 --- a/scripts/generate_conduit_data.pl +++ b/scripts/generate_conduit_data.pl @@ -187,10 +187,19 @@ BEGIN 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 @@ BEGIN 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";