Skip to content

Commit a99f38d

Browse files
committed
Merge branch 'master' into development
* master: (44 commits) Bug 2058149 - Remove Enterprise Products from the release tracking request automation Bumped version to 20260724.1 Bug 2057473 Bug 2056682 - Need to add Net::CIDR dependency to the base BMO perl image Bumped version to 20260723.2 Bug 2055861 Bug 2055285 - Remove the Show closed/merged PR checkbox in the GH PR view Bumped version to 20260723.1 Bug 2054574 - Do not auto-assigning Hackbot when submitting a Phabricator revision Bug 2055236 - The column headers in Github PR are barely visible in dark mode Bumped version to 20260714.1 Bug 2053416 Bug 2053697 Bumped version to 20260713.1 Bug 2053269 - BMO API bugzilla.login helper needs to support Bugzilla_api_token + cookie for authentication support Bug 2052048 - Hide "Close and move to Invalid Bugs" button for bugs reported by editbugs members Bug 2053330 - Close as Invalid button jumps next to Save Changes when a Resolve as button is clicked Bumped version to 20250707.1 Bug 2038147 Bug 2042314 - [HackerOne] GitHub PR webhook can write attachments to non-visible BMO bugs r=sheehan ...
2 parents 192d473 + 4f18e0a commit a99f38d

9 files changed

Lines changed: 148 additions & 102 deletions

File tree

‎Bugzilla/DB/Schema.pm‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,44 @@ use constant ABSTRACT_SCHEMA => {
758758
],
759759
},
760760

761+
flag_activity => {
762+
FIELDS => [
763+
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
764+
flag_when => {TYPE => 'DATETIME', NOTNULL => 1},
765+
type_id => {
766+
TYPE => 'INT2',
767+
NOTNULL => 1,
768+
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'},
769+
},
770+
flag_id => {TYPE => 'INT3', NOTNULL => 1},
771+
setter_id => {
772+
TYPE => 'INT3',
773+
NOTNULL => 1,
774+
REFERENCES => {TABLE => 'profiles', COLUMN => 'userid'},
775+
},
776+
requestee_id => {
777+
TYPE => 'INT3',
778+
REFERENCES => {TABLE => 'profiles', COLUMN => 'userid'},
779+
},
780+
bug_id => {
781+
TYPE => 'INT3',
782+
NOTNULL => 1,
783+
REFERENCES => {TABLE => 'bugs', COLUMN => 'bug_id', DELETE => 'CASCADE'},
784+
},
785+
attachment_id => {
786+
TYPE => 'INT5',
787+
REFERENCES => {TABLE => 'attachments', COLUMN => 'attach_id', DELETE => 'CASCADE'},
788+
},
789+
status => {TYPE => 'CHAR(1)', NOTNULL => 1},
790+
],
791+
INDEXES => [
792+
flag_activity_flag_id_idx => ['flag_id'],
793+
flag_activity_type_id_idx => ['type_id'],
794+
flag_activity_bug_id_idx => ['bug_id'],
795+
flag_activity_status_when_idx => ['status', 'flag_when'],
796+
],
797+
},
798+
761799
# "flagtypes" defines the types of flags that can be set.
762800
flagtypes => {
763801
FIELDS => [

‎Bugzilla/Flag.pm‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ whose names start with _ or a re specifically noted as being private.
4242
use Scalar::Util qw(blessed);
4343
use Storable qw(dclone);
4444

45+
use Bugzilla::FlagActivity;
4546
use Bugzilla::FlagType;
4647
use Bugzilla::Hook;
4748
use Bugzilla::User;
@@ -489,6 +490,18 @@ sub create {
489490
$params->{creation_date} = $params->{modification_date} = $timestamp;
490491

491492
$flag = $class->SUPER::create($params);
493+
494+
Bugzilla::FlagActivity->create({
495+
flag_when => $timestamp,
496+
setter_id => $flag->setter_id,
497+
status => $flag->status,
498+
type_id => $flag->type_id,
499+
flag_id => $flag->id,
500+
requestee_id => $flag->requestee_id,
501+
bug_id => $flag->bug_id,
502+
attachment_id => $flag->attach_id,
503+
});
504+
492505
return $flag;
493506
}
494507

@@ -505,6 +518,17 @@ sub update {
505518
$self->{'modification_date'}
506519
= format_time($timestamp, '%Y-%m-%d %T', Bugzilla->local_timezone);
507520
Bugzilla->memcached->clear({table => 'flags', id => $self->id});
521+
522+
Bugzilla::FlagActivity->create({
523+
flag_when => $timestamp,
524+
setter_id => $self->setter_id,
525+
status => $self->status,
526+
type_id => $self->type_id,
527+
flag_id => $self->id,
528+
requestee_id => $self->requestee_id,
529+
bug_id => $self->bug_id,
530+
attachment_id => $self->attach_id,
531+
});
508532
}
509533

510534
# BMO - provide a hook which passes the flag object
@@ -575,6 +599,18 @@ sub update_flags {
575599
# because that isn't passed to remove_from_db().
576600
Bugzilla::Hook::process('flag_deleted',
577601
{flag => $old_flag, timestamp => $timestamp});
602+
603+
Bugzilla::FlagActivity->create({
604+
flag_when => $timestamp,
605+
setter_id => Bugzilla->user->id || $old_flag->setter_id,
606+
status => 'X',
607+
type_id => $old_flag->type_id,
608+
flag_id => $old_flag->id,
609+
requestee_id => $old_flag->requestee_id,
610+
bug_id => $old_flag->bug_id,
611+
attachment_id => $old_flag->attach_id,
612+
});
613+
578614
$old_flag->remove_from_db();
579615
}
580616

@@ -685,6 +721,18 @@ sub force_retarget {
685721
my ($timestamp) = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
686722
Bugzilla::Hook::process('flag_deleted',
687723
{flag => $flag, timestamp => $timestamp});
724+
725+
Bugzilla::FlagActivity->create({
726+
flag_when => $timestamp,
727+
setter_id => Bugzilla->user->id || $flag->setter_id,
728+
status => 'X',
729+
type_id => $flag->type_id,
730+
flag_id => $flag->id,
731+
requestee_id => $flag->requestee_id,
732+
bug_id => $flag->bug_id,
733+
attachment_id => $flag->attach_id,
734+
});
735+
688736
$flag->remove_from_db();
689737
}
690738
}

extensions/Review/lib/FlagStateActivity.pm renamed to Bugzilla/FlagActivity.pm

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
# This Source Code Form is "Incompatible With Secondary Licenses", as
66
# defined by the Mozilla Public License, v. 2.0.
77

8-
package Bugzilla::Extension::Review::FlagStateActivity;
8+
package Bugzilla::FlagActivity;
99

1010
use 5.10.1;
1111
use strict;
1212
use warnings;
1313

14-
use Bugzilla::Error qw(ThrowUserError);
14+
use Bugzilla::Error;
1515
use Bugzilla::Util qw(trim datetime_from);
1616
use List::MoreUtils qw(none);
1717

1818
use base qw( Bugzilla::Object );
1919

20-
use constant DB_TABLE => 'flag_state_activity';
20+
use constant DB_TABLE => 'flag_activity';
2121
use constant LIST_ORDER => 'id';
2222
use constant AUDIT_CREATES => 0;
2323
use constant AUDIT_UPDATES => 0;
@@ -35,7 +35,6 @@ use constant DB_COLUMNS => qw(
3535
status
3636
);
3737

38-
3938
sub _check_param_required {
4039
my ($param) = @_;
4140

@@ -59,10 +58,6 @@ sub _check_date {
5958
sub _check_status {
6059
my ($self, $status) = @_;
6160

62-
# - Make sure the status is valid.
63-
# - Make sure the user didn't request the flag unless it's requestable.
64-
# If the flag existed and was requested before it became unrequestable,
65-
# leave it as is.
6661
if (none { $status eq $_ } qw( X + - ? )) {
6762
ThrowUserError('flag_status_invalid', {id => $self->id, status => $status});
6863
}

‎Bugzilla/Install/DB.pm‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,9 @@ sub update_table_definitions {
844844
# Bug 1949556 - dkl@mozilla.com
845845
$dbh->bz_add_index('audit_log', 'audit_log_object_id_idx', ['object_id']);
846846

847+
# Bug 1806896 - xavier.lhour@gmail.com
848+
_migrate_flag_state_activity();
849+
847850
################################################################
848851
# New --TABLE-- changes should go *** A B O V E *** this point #
849852
################################################################
@@ -4510,6 +4513,31 @@ sub _migrate_profiles_modification_ts {
45104513
{TYPE => 'DATETIME', NOTNULL => 1});
45114514
}
45124515

4516+
sub _migrate_flag_state_activity {
4517+
my $dbh = Bugzilla->dbh;
4518+
4519+
return unless $dbh->bz_table_info('flag_state_activity');
4520+
4521+
# Always copy, even if flag_activity already has rows: if a prior
4522+
# checksetup run created flag_activity but died before reaching this
4523+
# migration, live traffic can write new rows via Bugzilla::Flag in the
4524+
# meantime, and skipping here would orphan flag_state_activity forever.
4525+
#
4526+
# Copy rows into the already-indexed core flag_activity table instead of
4527+
# renaming flag_state_activity over it, which would discard its indexes.
4528+
# id is not carried over: nothing references flag_activity.id externally.
4529+
$dbh->do(
4530+
'INSERT INTO flag_activity
4531+
(flag_when, type_id, flag_id, setter_id, requestee_id, bug_id,
4532+
attachment_id, status)
4533+
SELECT flag_when, type_id, flag_id, setter_id, requestee_id, bug_id,
4534+
attachment_id, status
4535+
FROM flag_state_activity'
4536+
);
4537+
4538+
$dbh->bz_drop_table('flag_state_activity');
4539+
}
4540+
45134541
1;
45144542

45154543
__END__

‎extensions/BMO/bin/bug_1022707.pl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
print "Press <enter> to start, or ^C to cancel...\n";
3838
readline;
3939

40-
my $update_fsa_sql = "UPDATE flag_state_activity SET type_id = 4 WHERE "
40+
my $update_fsa_sql = "UPDATE flag_activity SET type_id = 4 WHERE "
4141
. $dbh->sql_in('flag_id', $flag_ids);
4242
my $update_flags_sql
4343
= "UPDATE flags SET type_id = 4 WHERE " . $dbh->sql_in('id', $flag_ids);

‎extensions/BMO/bin/export_bmo_etl.pl‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Bugzilla::Group;
2020
use Bugzilla::Logging;
2121
use Bugzilla::User;
22-
use Bugzilla::Extension::Review::FlagStateActivity;
22+
use Bugzilla::FlagActivity;
2323

2424
use HTTP::Headers;
2525
use HTTP::Request;
@@ -102,7 +102,7 @@
102102
process_bugs();
103103
process_attachments();
104104
process_flags();
105-
process_flag_state_activity();
105+
process_flag_activity();
106106
process_tracking_flags();
107107
process_keywords();
108108
process_see_also();
@@ -407,18 +407,18 @@ sub process_flags {
407407
}
408408
}
409409

410-
# Process flags that were removed today using the flag_state_activity table
410+
# Process flags that were removed today using the flag_activity table
411411
# These entries will also go into the flags table in BigQuery.
412-
sub process_flag_state_activity {
413-
my $table_name = 'flag_state_activity';
412+
sub process_flag_activity {
413+
my $table_name = 'flag_activity';
414414
my $total_count = 0;
415415
my $last_offset = 0;
416416

417417
logger("Processing $table_name.");
418418

419419
my $sth
420420
= $dbh->prepare(
421-
'SELECT id, flag_when FROM flag_state_activity WHERE status = \'X\' AND flag_when LIKE \''
421+
'SELECT id, flag_when FROM flag_activity WHERE status = \'X\' AND flag_when LIKE \''
422422
. $snapshot_date
423423
. ' %\' ORDER BY id LIMIT ? OFFSET ?');
424424

@@ -439,7 +439,7 @@ sub process_flag_state_activity {
439439
logger("$table_name id $id with time $mod_time not found in cache.",
440440
DEBUG_OUTPUT);
441441

442-
my $obj = Bugzilla::Extension::Review::FlagStateActivity->new($id);
442+
my $obj = Bugzilla::FlagActivity->new($id);
443443

444444
if (!$obj) {
445445
logger("Object $id not loaded from database or no longer exists");

‎extensions/Review/Extension.pm‎

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use Bugzilla;
1818
use Bugzilla::Config::Common qw(check_numeric);
1919
use Bugzilla::Constants;
2020
use Bugzilla::Error;
21-
use Bugzilla::Extension::Review::FlagStateActivity;
21+
use Bugzilla::FlagActivity;
2222
use Bugzilla::Extension::Review::Util;
2323
use Bugzilla::Install::Filesystem;
2424
use Bugzilla::Search;
@@ -369,10 +369,6 @@ sub object_end_of_create {
369369
_check_requestee($object);
370370
_adjust_request_count($object, +1);
371371
}
372-
if (_is_countable_flag($object)) {
373-
$self->_log_flag_state_activity($object, $object->status,
374-
$object->modification_date);
375-
}
376372
}
377373

378374
sub object_end_of_update {
@@ -461,9 +457,6 @@ sub flag_updated {
461457
my $changes = $args->{changes};
462458

463459
return unless scalar(keys %$changes);
464-
if (_is_countable_flag($flag)) {
465-
$self->_log_flag_state_activity($flag, $flag->status, $timestamp);
466-
}
467460
}
468461

469462
sub flag_deleted {
@@ -475,9 +468,6 @@ sub flag_deleted {
475468
_adjust_request_count($flag, -1);
476469
}
477470

478-
if (_is_countable_flag($flag)) {
479-
$self->_log_flag_state_activity($flag, 'X', $timestamp, Bugzilla->user->id);
480-
}
481471
}
482472

483473
sub _is_countable_flag {
@@ -503,22 +493,6 @@ sub _check_requestee {
503493
}
504494
}
505495

506-
sub _log_flag_state_activity {
507-
my ($self, $flag, $status, $timestamp, $setter_id) = @_;
508-
509-
$setter_id //= $flag->setter_id;
510-
511-
Bugzilla::Extension::Review::FlagStateActivity->create({
512-
flag_when => $timestamp,
513-
setter_id => $setter_id,
514-
status => $status,
515-
type_id => $flag->type_id,
516-
flag_id => $flag->id,
517-
requestee_id => $flag->requestee_id,
518-
bug_id => $flag->bug_id,
519-
attachment_id => $flag->attach_id,
520-
});
521-
}
522496

523497
sub _adjust_request_count {
524498
my ($flag, $add) = @_;
@@ -850,45 +824,6 @@ sub db_schema_abstract_schema {
850824
],
851825
};
852826

853-
$args->{'schema'}->{'flag_state_activity'} = {
854-
FIELDS => [
855-
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1,},
856-
857-
flag_when => {TYPE => 'DATETIME', NOTNULL => 1,},
858-
859-
type_id => {
860-
TYPE => 'INT2',
861-
NOTNULL => 1,
862-
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
863-
},
864-
865-
flag_id => {TYPE => 'INT3', NOTNULL => 1,},
866-
867-
setter_id => {
868-
TYPE => 'INT3',
869-
NOTNULL => 1,
870-
REFERENCES => {TABLE => 'profiles', COLUMN => 'userid',},
871-
},
872-
873-
requestee_id =>
874-
{TYPE => 'INT3', REFERENCES => {TABLE => 'profiles', COLUMN => 'userid',},},
875-
876-
bug_id => {
877-
TYPE => 'INT3',
878-
NOTNULL => 1,
879-
REFERENCES => {TABLE => 'bugs', COLUMN => 'bug_id', DELETE => 'CASCADE'}
880-
},
881-
882-
attachment_id => {
883-
TYPE => 'INT5',
884-
REFERENCES =>
885-
{TABLE => 'attachments', COLUMN => 'attach_id', DELETE => 'CASCADE'}
886-
},
887-
888-
status => {TYPE => 'CHAR(1)', NOTNULL => 1,},
889-
],
890-
};
891-
892827
$args->{'schema'}->{'bug_mentors'} = {
893828
FIELDS => [
894829
bug_id => {
@@ -930,6 +865,7 @@ sub db_schema_abstract_schema {
930865

931866
sub install_update_db {
932867
my $dbh = Bugzilla->dbh;
868+
933869
$dbh->bz_add_column('products', 'reviewer_required',
934870
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'});
935871
$dbh->bz_add_column('profiles', 'review_request_count',
@@ -954,7 +890,8 @@ sub install_update_db {
954890
}
955891

956892
# Bug 1588221 - dkl@mozilla.com
957-
$dbh->bz_alter_column('flag_state_activity', 'attachment_id', {TYPE => 'INT5'});
893+
# Bug 1806896 - table renamed from flag_state_activity to flag_activity
894+
$dbh->bz_alter_column('flag_activity', 'attachment_id', {TYPE => 'INT5'});
958895
}
959896

960897
sub install_filesystem {

0 commit comments

Comments
 (0)