Closed
Bug 283926
Opened 21 years ago
Closed 19 years ago
Make process_bug add comments by using Bugzilla::Bug
Categories
(Bugzilla :: Creating/Changing Bugs, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 3.2
People
(Reporter: mkanat, Assigned: mkanat)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 6 obsolete files)
|
6.62 KB,
patch
|
LpSolit
:
review+
|
Details | Diff | Splinter Review |
There should be an add_comment function. It should itself call the code in
ValidateComment, so we don't have use that externally anymore.
This should be a very easy start to bug 122922.
Attachment #207187 -
Flags: review?(mkanat)
| Assignee | ||
Comment 2•20 years ago
|
||
Comment on attachment 207187 [details] [diff] [review]
added the function add_comment
1) bug_id($self) won't work, that's not how Object-Oriented stuff in perl works.
2) I'd like to actually get rid of AppendComment entirely and *refactor* its code into add_comment.
Attachment #207187 -
Flags: review?(mkanat) → review-
Attachment #207187 -
Attachment is obsolete: true
Attachment #207193 -
Flags: review?(mkanat)
| Assignee | ||
Updated•20 years ago
|
Assignee: create-and-change → pdemarco
| Assignee | ||
Comment 4•20 years ago
|
||
Comment on attachment 207193 [details] [diff] [review]
removed AppendComment() and changed all calling code
As I said in IRC:
I'm a little uncertain about the safety of this patch when/if the bug object comes up undefined.
Also, we should create the bug object much higher in the script, so that other patches can use it in the future.
And add_comment should probably clear {longdescs} if it exists.
And finally, I'd like to see it used named parameters (with sensible defaults) for everything except the comment text.
Attachment #207193 -
Flags: review?(mkanat) → review-
| Assignee | ||
Comment 5•20 years ago
|
||
And where possible, I'd like to call it $bug instead of $bugobj, but if that variable name is already taken, I understand.
Status: NEW → ASSIGNED
Target Milestone: --- → Bugzilla 2.24
(In reply to comment #5)
> And where possible, I'd like to call it $bug instead of $bugobj, but if that
> variable name is already taken, I understand.
>
Not normally a nice thing to do. It helps slightly in typing the identifier, but is harmful for debugging.
For example I have to look through this to find what I'm looking for.
http://landfill.bugzilla.org/mxr/bugzilla/search?string=%5C%24bug
Attachment #207193 -
Attachment is obsolete: true
Attachment #207345 -
Flags: review?(mkanat)
| Assignee | ||
Updated•20 years ago
|
Blocks: bz-postbugpm
| Assignee | ||
Updated•20 years ago
|
No longer blocks: bz-bugwrite
| Assignee | ||
Comment 8•20 years ago
|
||
Comment on attachment 207345 [details] [diff] [review]
Implemented suggested changes
This *looks* generally great. :-) Except that I'd rather you just added "who" to the (new) _validate_attribute sub instead of calling it "inspector."
Attachment #207345 -
Flags: review?(mkanat)
Attachment #207345 -
Flags: review?(LpSolit)
Attachment #207345 -
Flags: review+
| Assignee | ||
Updated•20 years ago
|
Severity: normal → enhancement
Comment 9•20 years ago
|
||
Comment on attachment 207345 [details] [diff] [review]
Implemented suggested changes
Bug.pm still tries to export AppendComment() despite this function no longer exists. And Bug::CheckIfVotedConfirmed() still uses AppendComment(), doesn't find it and crashes (I didn't test, but this seems pretty obvious).
Attachment #207345 -
Flags: review?(LpSolit) → review-
Comment 10•20 years ago
|
||
(In reply to comment #8)
> (From update of attachment 207345 [details] [diff] [review] [edit])
> This *looks* generally great. :-) Except that I'd rather you just added "who"
> to the (new) _validate_attribute sub instead of calling it "inspector."
>
Oh, and I second mkanat's comment. Use 'who' instead of 'inspector'.
Comment 11•20 years ago
|
||
(In reply to comment #10)
> (In reply to comment #8)
>
> Oh, and I second mkanat's comment. Use 'who' instead of 'inspector'.
>
Because you don't like to have self documenting code? who? who? who?
who's looking at the bug?
who's commented on the bug?
who's assigned to the bug?
who's reported the bug?
I agree let's call them all "$who" !!!
| Assignee | ||
Comment 12•20 years ago
|
||
(In reply to comment #11)
> Because you don't like to have self documenting code? who? who? who?
> who's looking at the bug?
> who's commented on the bug?
> who's assigned to the bug?
> who's reported the bug?
Yes, "who" could be unclear, but it's what we already use. If you want it to be more consistent, you can also change the fact that the internal Bug field is called "who". That would be fine. I'm not sure I like "inspector," but it's definitely possible we could come up with something clearer than "who." Naming variables can definitely be quite a mental task. :-)
Also, I understand the need for discussion, but that can be done in IRC if you feel frustrated by something. Please don't put inflamatory comments into Bugzilla. They stay here forever.
Comment 13•19 years ago
|
||
changes from 207345:
s/inspector/who/g
remove AppendComment from @Bugzilla::Bug::EXPORT
previous patch caused 'Global symbol "$bug_obj" requires explicit package name at process_bug.cgi line 1693.'
-> + my $bug_obj = new Bugzilla::Bug($id, $whoid);
Attachment #207345 -
Attachment is obsolete: true
Attachment #225209 -
Flags: review?(LpSolit)
Comment 14•19 years ago
|
||
Comment on attachment 225209 [details] [diff] [review]
updated
>Index: attachment.cgi
You forgot AppendComment() around line 1390:
# Paste the reason provided by the admin into a comment.
AppendComment($bug_id, $user->id, $msg);
>Index: process_bug.cgi
>@@ -1690,8 +1690,11 @@
>+ my $bug_obj = new Bugzilla::Bug($id, $whoid);
Use the existing $old_bug_obj bug object.
>Index: Bugzilla/Bug.pm
>+sub who { $_[0]->{'who'}; }
"who" is too vague. Probably "applicant" would be better. You could also add a comment which specifies that "applicant" is the user account used to build the bug object.
>+sub add_comment {
>+ $params->{'isprivate'} ||= 0;
Instead of defining $privacyval later, you should validate 'isprivate' here:
$params->{'isprivate'} = $params->{'isprivate'} ? 1 : 0;
>+ #must be logged in to add a comment
>+ if (! $params->{'whoid'}) {
>+ return;
>+ }
Nit: You could write this in a single line: return unless $params->{'whoid'}. Moreover, as $params->{'whoid'} is used only once, I'm not sure it worths defining this variable. You could use $self->who->id directly.
>+ my $privacyval = $params->{'isprivate'} ? 1 : 0;
As said above, this variable is useless.
>+ my $votedconfirmedbug = new Bugzilla::Bug($id, $who);
>+ $votedconfirmedbug->add_comment("*** This bug has been confirmed" .
>+ " by popular vote. ***",
>+ {'timestamp' => $timestamp});
>+
> AppendComment($id, $who,
> "*** This bug has been confirmed by popular vote. ***",
> 0, $timestamp);
Hrm... Remove AppendComment() now that you use add_comment()! :)
Note that there is a small bitrot in Bug.pm. Else the patch looks good.
Attachment #225209 -
Flags: review?(LpSolit) → review-
Comment 15•19 years ago
|
||
Attachment #225209 -
Attachment is obsolete: true
Attachment #226011 -
Flags: review?(LpSolit)
Comment 16•19 years ago
|
||
Attachment #226011 -
Attachment is obsolete: true
Attachment #226038 -
Flags: review?(LpSolit)
Attachment #226011 -
Flags: review?(LpSolit)
Comment 17•19 years ago
|
||
Bugzilla::Bug::CheckIfVotedConfirmed() needs to be fixed in order to use add_comment(), but CheckIfVotedConfirmed() is called in votes.cgi while tables are locked. This means that:
1) you have to lock all missing tables in votes.cgi. I hate to lock extra tables though, this slows down the system. I wrote a patch to remove some useless locked tables and I don't want to bring them back. We keep having regressions when building bug objects while tables are locked.
2) create these bug objects outside the lock. I much prefer this solution.
3) make bug object creation much lighter. This solution is even better!! :)
I strongly prefer solution 3). I would be tempted to r- any patch implementing 1).
Comment 18•19 years ago
|
||
Comment on attachment 226038 [details] [diff] [review]
update 226011 due to bug 5179
per my previous comment.
Attachment #226038 -
Flags: review?(LpSolit) → review-
Comment 19•19 years ago
|
||
(In reply to comment #17)
> 3) make bug object creation much lighter. This solution is even better!! :)
>
> I strongly prefer solution 3).
This solution has finally been implemented (or fixed). This means that it's now easy to update this patch.
Comment 21•19 years ago
|
||
This bug is retargetted to Bugzilla 3.2 for one of the following reasons:
- it has no assignee (except the default one)
- we don't expect someone to fix it in the next two weeks (i.e. before we freeze the trunk to prepare Bugzilla 3.0 RC1)
- it's not a blocker
If you are working on this bug and you think you will be able to submit a patch in the next two weeks, retarget this bug to 3.0.
If this bug is something you would like to see implemented in 3.0 but you are not a developer or you don't think you will be able to fix this bug yourself in the next two weeks, please *do not* retarget this bug.
If you think this bug should absolutely be fixed before we release 3.0, either ask on IRC or use the "blocking3.0 flag".
Target Milestone: Bugzilla 3.0 → Bugzilla 3.2
Updated•19 years ago
|
Attachment #226038 -
Attachment is obsolete: true
| Assignee | ||
Comment 22•19 years ago
|
||
We're going to re-purpose this bug slightly, and narrow its focus. We're just going to replace the AppendComment calls in process_bug with a call to $bug->add_comment( ) and then $bug->update(). This will be a simple way to get started on $bug->update and also get rid of some calls to AppendComment.
Blocks: bz-process_bug
Summary: Refactor AppendComment into Bugzilla::Bug::add_comment → Make process_bug add comments by using Bugzilla::Bug
| Assignee | ||
Comment 23•19 years ago
|
||
Okay, here we are. I tested this on landfill with bug moving, dup'ing, and just adding a normal comment.
It theoretically depends on my patch from bug 371070, but it may not actually require that code in order to work.
Assignee: create-and-change → mkanat
Status: NEW → ASSIGNED
Attachment #255850 -
Flags: review?(LpSolit)
Comment 24•19 years ago
|
||
Comment on attachment 255850 [details] [diff] [review]
v1
You should kill AppendComment() entirely, IMO, i.e. removing it from attachment.cgi.
r=LpSolit
Attachment #255850 -
Flags: review?(LpSolit) → review+
Updated•19 years ago
|
Flags: approval+
Comment 25•19 years ago
|
||
Comment on attachment 255850 [details] [diff] [review]
v1
>diff -u Bugzilla/Bug.pm Bugzilla/Bug.pm
>+#####################################################################
>+# Mutators
>+#####################################################################
>+
>+ |<-- TAB
Please remove the tab on the last line above:
t/005no_tabs.........NOK 62
# Failed test 'Bugzilla/Bug.pm contains tabs --WARNING'
| Assignee | ||
Comment 26•19 years ago
|
||
Oops, I checked this in but somehow didn't commit the checkin message here. Anyhow, here are the revisions:
process_bug.cgi: revision 1.353
Bugzilla/Bug.pm: revision 1.174
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•