Skip to content

Commit 775b7cc

Browse files
author
David Lawrence
committed
Merge remote branch 'origin/master'
2 parents 1af952c + 24a16ae commit 775b7cc

File tree

6 files changed

+132
-57
lines changed

6 files changed

+132
-57
lines changed

Bugzilla/DB/Schema.pm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,25 @@ use constant ABSTRACT_SCHEMA => {
17141714
],
17151715
},
17161716

1717+
bug_user_last_visit => {
1718+
FIELDS => [
1719+
id => {TYPE => 'INTSERIAL', NOTNULL => 1,
1720+
PRIMARYKEY => 1},
1721+
user_id => {TYPE => 'INT3', NOTNULL => 1,
1722+
REFERENCES => {TABLE => 'profiles',
1723+
COLUMN => 'userid',
1724+
DELETE => 'CASCADE'}},
1725+
bug_id => {TYPE => 'INT3', NOTNULL => 1,
1726+
REFERENCES => {TABLE => 'bugs',
1727+
COLUMN => 'bug_id',
1728+
DELETE => 'CASCADE'}},
1729+
last_visit_ts => {TYPE => 'DATETIME', NOTNULL => 1},
1730+
],
1731+
INDEXES => [
1732+
bug_user_last_visit_idx => {FIELDS => ['user_id', 'bug_id'],
1733+
TYPE => 'UNIQUE'}
1734+
],
1735+
},
17171736
};
17181737

17191738
# Foreign Keys are added in Bugzilla::DB::bz_add_field_tables

Bugzilla/Memcached.pm

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ sub set_config {
106106
return unless $self->{memcached};
107107

108108
if (exists $args->{key}) {
109-
return $self->_set($self->_config_prefix . ':' . $args->{key}, $args->{data});
109+
return $self->_set($self->_config_prefix . '.' . $args->{key}, $args->{data});
110110
}
111111
else {
112112
ThrowCodeError('params_required', { function => "Bugzilla::Memcached::set_config",
@@ -119,7 +119,7 @@ sub get_config {
119119
return unless $self->{memcached};
120120

121121
if (exists $args->{key}) {
122-
return $self->_get($self->_config_prefix . ':' . $args->{key});
122+
return $self->_get($self->_config_prefix . '.' . $args->{key});
123123
}
124124
else {
125125
ThrowCodeError('params_required', { function => "Bugzilla::Memcached::get_config",
@@ -167,9 +167,14 @@ sub clear_all {
167167
}
168168

169169
sub clear_config {
170-
my ($self) = @_;
170+
my ($self, $args) = @_;
171171
return unless $self->{memcached};
172-
$self->_inc_prefix("config");
172+
if ($args && exists $args->{key}) {
173+
$self->_delete($self->_config_prefix . '.' . $args->{key});
174+
}
175+
else {
176+
$self->_inc_prefix("config");
177+
}
173178
}
174179

175180
# in order to clear all our keys, we add a prefix to all our keys. when we
@@ -221,7 +226,7 @@ sub _config_prefix {
221226

222227
sub _encode_key {
223228
my ($self, $key) = @_;
224-
$key = $self->_global_prefix . ':' . uri_escape_utf8($key);
229+
$key = $self->_global_prefix . '.' . uri_escape_utf8($key);
225230
return length($self->{namespace} . $key) > MAX_KEY_LENGTH
226231
? undef
227232
: $key;
@@ -426,6 +431,11 @@ corresponding C<table> and C<name> entry.
426431
Removes C<value> with the specified C<table> and C<name>, as well as the
427432
corresponding C<table> and C<id> entry.
428433
434+
=item C<clear_config({ key =E<gt> $key })>
435+
436+
Remove C<value> with the specified C<key> from the configuration cache. See
437+
C<set_config> for more information.
438+
429439
=item C<clear_config>
430440
431441
Removes all configuration related values from the cache. See C<set_config> for

Bugzilla/User.pm

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -677,63 +677,75 @@ sub groups {
677677
return $self->{groups} if defined $self->{groups};
678678
return [] unless $self->id;
679679

680-
my $dbh = Bugzilla->dbh;
681-
my $groups_to_check = $dbh->selectcol_arrayref(
682-
q{SELECT DISTINCT group_id
683-
FROM user_group_map
684-
WHERE user_id = ? AND isbless = 0}, undef, $self->id);
685-
686-
my $cache_key = 'group_grant_type_' . GROUP_MEMBERSHIP;
687-
my $membership_rows = Bugzilla->memcached->get_config({
688-
key => $cache_key,
680+
my $user_groups_key = "user_groups." . $self->id;
681+
my $groups = Bugzilla->memcached->get_config({
682+
key => $user_groups_key
689683
});
690-
if (!$membership_rows) {
691-
$membership_rows = $dbh->selectall_arrayref(
692-
"SELECT DISTINCT grantor_id, member_id
693-
FROM group_group_map
694-
WHERE grant_type = " . GROUP_MEMBERSHIP);
695-
Bugzilla->memcached->set_config({
696-
key => $cache_key,
697-
data => $membership_rows,
684+
685+
if (!$groups) {
686+
my $dbh = Bugzilla->dbh;
687+
my $groups_to_check = $dbh->selectcol_arrayref(
688+
"SELECT DISTINCT group_id
689+
FROM user_group_map
690+
WHERE user_id = ? AND isbless = 0", undef, $self->id);
691+
692+
my $grant_type_key = 'group_grant_type_' . GROUP_MEMBERSHIP;
693+
my $membership_rows = Bugzilla->memcached->get_config({
694+
key => $grant_type_key,
698695
});
699-
}
696+
if (!$membership_rows) {
697+
$membership_rows = $dbh->selectall_arrayref(
698+
"SELECT DISTINCT grantor_id, member_id
699+
FROM group_group_map
700+
WHERE grant_type = " . GROUP_MEMBERSHIP);
701+
Bugzilla->memcached->set_config({
702+
key => $grant_type_key,
703+
data => $membership_rows,
704+
});
705+
}
700706

701-
my %group_membership;
702-
foreach my $row (@$membership_rows) {
703-
my ($grantor_id, $member_id) = @$row;
704-
push (@{ $group_membership{$member_id} }, $grantor_id);
705-
}
706-
707-
# Let's walk the groups hierarchy tree (using FIFO)
708-
# On the first iteration it's pre-filled with direct groups
709-
# membership. Later on, each group can add its own members into the
710-
# FIFO. Circular dependencies are eliminated by checking
711-
# $checked_groups{$member_id} hash values.
712-
# As a result, %groups will have all the groups we are the member of.
713-
my %checked_groups;
714-
my %groups;
715-
while (scalar(@$groups_to_check) > 0) {
716-
# Pop the head group from FIFO
717-
my $member_id = shift @$groups_to_check;
718-
719-
# Skip the group if we have already checked it
720-
if (!$checked_groups{$member_id}) {
721-
# Mark group as checked
722-
$checked_groups{$member_id} = 1;
723-
724-
# Add all its members to the FIFO check list
725-
# %group_membership contains arrays of group members
726-
# for all groups. Accessible by group number.
727-
my $members = $group_membership{$member_id};
728-
my @new_to_check = grep(!$checked_groups{$_}, @$members);
729-
push(@$groups_to_check, @new_to_check);
730-
731-
$groups{$member_id} = 1;
707+
my %group_membership;
708+
foreach my $row (@$membership_rows) {
709+
my ($grantor_id, $member_id) = @$row;
710+
push (@{ $group_membership{$member_id} }, $grantor_id);
732711
}
733-
}
734712

735-
$self->{groups} = Bugzilla::Group->new_from_list([keys %groups]);
713+
# Let's walk the groups hierarchy tree (using FIFO)
714+
# On the first iteration it's pre-filled with direct groups
715+
# membership. Later on, each group can add its own members into the
716+
# FIFO. Circular dependencies are eliminated by checking
717+
# $checked_groups{$member_id} hash values.
718+
# As a result, %groups will have all the groups we are the member of.
719+
my %checked_groups;
720+
my %groups;
721+
while (scalar(@$groups_to_check) > 0) {
722+
# Pop the head group from FIFO
723+
my $member_id = shift @$groups_to_check;
724+
725+
# Skip the group if we have already checked it
726+
if (!$checked_groups{$member_id}) {
727+
# Mark group as checked
728+
$checked_groups{$member_id} = 1;
729+
730+
# Add all its members to the FIFO check list
731+
# %group_membership contains arrays of group members
732+
# for all groups. Accessible by group number.
733+
my $members = $group_membership{$member_id};
734+
my @new_to_check = grep(!$checked_groups{$_}, @$members);
735+
push(@$groups_to_check, @new_to_check);
736+
737+
$groups{$member_id} = 1;
738+
}
739+
}
740+
$groups = [ keys %groups ];
741+
742+
Bugzilla->memcached->set_config({
743+
key => $user_groups_key,
744+
data => $groups,
745+
});
746+
}
736747

748+
$self->{groups} = Bugzilla::Group->new_from_list($groups);
737749
return $self->{groups};
738750
}
739751

@@ -1343,6 +1355,8 @@ sub derive_regexp_groups {
13431355
$group_delete->execute($id, $group, GRANT_REGEXP) if $present;
13441356
}
13451357
}
1358+
1359+
Bugzilla->memcached->clear_config({ key => "user_groups.$id" });
13461360
}
13471361

13481362
sub product_responsibilities {

editusers.cgi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ if ($action eq 'search') {
342342
($otherUserID, $userid,
343343
get_field_id('bug_group'),
344344
join(', ', @groupsRemovedFrom), join(', ', @groupsAddedTo)));
345+
Bugzilla->memcached->clear_config({ key => "user_groups.$otherUserID" })
345346
}
346347
# XXX: should create profiles_activity entries for blesser changes.
347348

extensions/BMO/lib/Reports/UserActivity.pm

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ sub report {
5454

5555
my ($activity_joins, $activity_where) = ('', '');
5656
my ($attachments_joins, $attachments_where) = ('', '');
57+
my ($tags_activity_joins, $tags_activity_where) = ('', '');
5758
if (Bugzilla->params->{"insidergroup"}
5859
&& !Bugzilla->user->in_group(Bugzilla->params->{'insidergroup'}))
5960
{
6061
$activity_joins = "LEFT JOIN attachments
6162
ON attachments.attach_id = bugs_activity.attach_id";
6263
$activity_where = "AND COALESCE(attachments.isprivate, 0) = 0";
6364
$attachments_where = $activity_where;
65+
66+
$tags_activity_joins = 'LEFT JOIN longdescs
67+
ON longdescs_tags_activity.comment_id = longdescs.comment_id';
68+
$tags_activity_where = 'AND COALESCE(longdescs.isprivate, 0) = 0';
6469
}
6570

6671
my @who_bits;
@@ -92,7 +97,7 @@ sub report {
9297
$from_dt = $from_dt->ymd() . ' 00:00:00';
9398
$to_dt = $to_dt->ymd() . ' 23:59:59';
9499
my @params;
95-
for (1..4) {
100+
for (1..5) {
96101
push @params, @who;
97102
push @params, ($from_dt, $to_dt);
98103
}
@@ -128,6 +133,28 @@ sub report {
128133
129134
UNION ALL
130135
136+
SELECT
137+
'comment_tag' AS name,
138+
longdescs_tags_activity.bug_id,
139+
NULL as attach_id,
140+
".$dbh->sql_date_format('longdescs_tags_activity.bug_when',
141+
'%Y.%m.%d %H:%i:%s') . " AS bug_when,
142+
longdescs_tags_activity.removed,
143+
longdescs_tags_activity.added,
144+
profiles.login_name,
145+
longdescs_tags_activity.comment_id,
146+
longdescs_tags_activity.bug_when
147+
FROM longdescs_tags_activity
148+
$tags_activity_joins
149+
INNER JOIN profiles
150+
ON profiles.userid = longdescs_tags_activity.who
151+
WHERE profiles.login_name IN ($who_bits)
152+
AND longdescs_tags_activity.bug_when >= ?
153+
AND longdescs_tags_activity.bug_when <= ?
154+
$tags_activity_where
155+
156+
UNION ALL
157+
131158
SELECT
132159
'bug_id' AS name,
133160
bugs.bug_id,

extensions/BMO/template/en/default/pages/user_activity.html.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
[% "Comment $change.comment.count"
161161
FILTER bug_link(operation.bug, comment_num => change.comment.count)
162162
FILTER none %]
163+
[% ELSIF change.comment.defined && change.fieldname == 'comment_tag' %]
164+
[% "Comment $change.comment.count Tagged"
165+
FILTER bug_link(operation.bug, comment_num => change.comment.count)
166+
FILTER none %]
163167
[% ELSE %]
164168
[%+ field_descs.${change.fieldname} FILTER html %]
165169
[% END %]

0 commit comments

Comments
 (0)