Closed
Bug 384664
Opened 18 years ago
Closed 18 years ago
Make keywords use Bugzilla::Bug in process_bug
Categories
(Bugzilla :: Creating/Changing Bugs, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 3.2
People
(Reporter: mkanat, Assigned: mkanat)
References
Details
Attachments
(1 file, 4 obsolete files)
14.92 KB,
patch
|
LpSolit
:
review+
|
Details | Diff | Splinter Review |
Now that CCs are done, the next-easiest thing to do is to make Keywords use the bug objects in process_bug.cgi.
Assignee | ||
Comment 1•18 years ago
|
||
Here we go! Works very nicely. :-)
Attachment #268585 -
Flags: review?(LpSolit)
Assignee | ||
Comment 2•18 years ago
|
||
Updated to apply against v3 of the CC bug.
Attachment #268585 -
Attachment is obsolete: true
Attachment #268589 -
Flags: review?(LpSolit)
Attachment #268585 -
Flags: review?(LpSolit)
Assignee | ||
Comment 3•18 years ago
|
||
I fixed the bitrot.
By the way, I forgot to mention it, but you'll notice I cleaned up the {prod_obj} stuff in Bugzilla::Bug in this patch.
Attachment #268589 -
Attachment is obsolete: true
Attachment #269293 -
Flags: review?(LpSolit)
Attachment #268589 -
Flags: review?(LpSolit)
![]() |
||
Comment 4•18 years ago
|
||
Comment on attachment 269293 [details] [diff] [review]
v1.2
>diff -u process_bug.cgi process_bug.cgi
>@@ -108,7 +108,7 @@
>-my @idlist;
>+my (@idlist, @bug_objects);
>@@ -117,12 +117,15 @@
>+ push(@bug_objects, new Bugzilla::Bug($id));
>@@ -136,7 +139,7 @@
>-my (@idlist, @bug_objects);
>+my @idlist;
>@@ -145,15 +148,12 @@
>- push(@bug_objects, new Bugzilla::Bug($id));
No idea how I'm supposed to read this patch. It contains blocks which undo what has been done above. Looks like 2 patches have been mixed.
Attachment #269293 -
Flags: review?(LpSolit) → review-
Assignee | ||
Comment 5•18 years ago
|
||
Oh, weird! Sorry about that! Here's the right patch.
Attachment #269293 -
Attachment is obsolete: true
Attachment #269767 -
Flags: review?(LpSolit)
![]() |
||
Comment 6•18 years ago
|
||
Comment on attachment 269767 [details] [diff] [review]
v1.3
>diff -u process_bug.cgi process_bug.cgi
>+ foreach my $b (@bug_objects) {
>+ $any_keyword_changes =
>+ $b->modify_keywords($cgi->param('keywords'),
>+ scalar $cgi->param('keywordaction'));
> }
$any_keyword_changes takes the value of the last bug being processed. With keywordaction = makeexact, if the returned value is 0 for the last bug, then you will incorrectly assume no changes have been made about keywords, even if there were some for other bugs.
Also, you should write |scalar $cgi->param()| as it's really a scalar.
>diff -u Bugzilla/Bug.pm Bugzilla/Bug.pm
>+sub update_keywords {
>+ foreach my $keyword_id (@$removed) {
>+ $dbh->do('DELETE FROM keywords WHERE bug_id = ? AND keywordid = ?',
>+ undef, $self->id, $keyword_id);
>+ }
Either prepare the statement outside the foreach loop or write
|keywordid IN (...)|.
>+ foreach my $keyword_id (@$added) {
>+ $dbh->do('INSERT INTO keywords (bug_id, keywordid) VALUES (?,?)',
>+ undef, $self->id, $keyword_id);
>+ }
Prepare the statement outside the foreach loop.
>+ my $removed_names = join ', ', (map {$_->name} @$removed_keywords);
>+ my $added_names = join ', ', (map {$_->name} @$added_keywords);
Nit: please add parens when using join(). This is clearer.
>+ return [$removed_keywords, $added_keywords];
Be consistent with update_cc() and return an array instead of an arrayref.
>+# There was a lot of duplicate code when I wrote this as three separate
>+# functions, so I just combined them all into one. This is also easier for
>+# process_bug to use.
>+sub modify_keywords {
I don't see why this comment is useful. Just remove it!
>+ my @all_changes = map { @$_ } diff_arrays(\@old_ids, \@new_ids);
>+ $any_changes = scalar @all_changes;
I don't like map {@$_}. You could as well write:
my ($removed, $added) = diff_arrays(\@old_ids, \@new_ids);
$any_changes = scalar(@$removed) || scalar(@$added);
>+sub keyword_objects {
>+ $self->{'keyword_objects'} = Bugzilla::Keyword->new_from_list($ids);
> }
You have to return $self->{'keyword_objects'}.
Attachment #269767 -
Flags: review?(LpSolit) → review-
Assignee | ||
Comment 7•18 years ago
|
||
Just a few responses:
* Good idea about removing @all_changes.
* Oh, all the functions are supposed to return an arrayref, since they'll eventually be part of $changes in update()! I guess I wasn't paying attention when I made update_cc return an array. We'll have to fix that later, when we combine all the update() functions.
* I really don't see the point of optimizing update_keywords with prepared statements.
Assignee | ||
Comment 8•18 years ago
|
||
Oh, and the comment is useful to explain why that one function is different from all the rest, so that somebody doesn't try to refactor it in the future. So it's staying.
Assignee | ||
Comment 9•18 years ago
|
||
Here--this should fix everything I didn't respond to.
Attachment #269767 -
Attachment is obsolete: true
Attachment #270538 -
Flags: review?(LpSolit)
![]() |
||
Comment 10•18 years ago
|
||
(In reply to comment #7)
> * I really don't see the point of optimizing update_keywords with prepared
> statements.
We do it everywhere else within the Bugzilla code. Everytime we have a loop, we prepare the statements outside the loop. I don't see why we should do an exception here. Moreover, the docs say it's faster to prepare the statement only once that calling ->do() everytime.
![]() |
||
Comment 11•18 years ago
|
||
Comment on attachment 270538 [details] [diff] [review]
v2
>Index: Bugzilla/Bug.pm
>+sub update_keywords {
>+ if (scalar @$removed || scalar @$added) {
>+ my $removed_names = join ', ', (map {$_->name} @$removed_keywords);
>+ my $added_names = join ', ', (map {$_->name} @$added_keywords);
Nit: please add parens -> join().
>+sub modify_keywords {
>+ my $new = join(', ', \@result);
This should be:
my $new = join(', ', map {$_->name} @result);
Your patch is working fine. r=LpSolit with the changes above.
Attachment #270538 -
Flags: review?(LpSolit) → review+
![]() |
||
Updated•18 years ago
|
Flags: approval+
Assignee | ||
Comment 12•18 years ago
|
||
Hey, thanks for catching that error, there! :-) I fixed both the things you mentioned.
Checking in process_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v <-- process_bug.cgi
new revision: 1.370; previous revision: 1.369
done
Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v <-- Bug.pm
new revision: 1.185; previous revision: 1.184
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•