Closed Bug 395451 Opened 17 years ago Closed 14 years ago

Bugzilla::BugMail needs to use Bug objects internally instead of direct SQL

Categories

(Bugzilla :: Email Notifications, enhancement)

3.1.1
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.0

People

(Reporter: mkanat, Assigned: reed)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 5 obsolete files)

Right now Bugzilla::BugMail does all sorts of complicated things to populate %values in its Send() subroutine. All of this data could easily be gotten from a single Bugzilla::Bug object.

Once we have multi-select fields, this will be particularly important, since the values of multi-select fields aren't stored in the bug table, and thus won't show up in "New: " bugmails unless we do this.
Attached patch WIP (obsolete) — Splinter Review
This is a work-in-progress. It compiles, but it almost certainly doesn't work yet.
Bugzilla 3.2 is now frozen. Only enhancements blocking 3.2 or specifically approved for 3.2 may be checked in to the 3.2 branch. If you would like to nominate your enhancement for Bugzilla 3.2, set the "blocking3.2" flag to "?", and either the target milestone will be changed back, or the blocking3.2 flag will be granted, if we will accept this enhancement for Bugzilla 3.2.
Target Milestone: Bugzilla 3.2 → Bugzilla 4.0
Blocks: 390586
Attached patch wip rev 2 (obsolete) — Splinter Review
This is blocking a bug I'm working on, so I'm going to take this.
Assignee: mkanat → reed
Attachment #280130 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Target Milestone: Bugzilla 4.0 → Bugzilla 3.8
Attached patch wip rev 3 (obsolete) — Splinter Review
runtests.pl passes fine with this. Still yet to actually test it, however. That's next.

https://landfill.bugzilla.org/bz395451/
Attachment #442589 - Attachment is obsolete: true
Attached patch patch - v1 (obsolete) — Splinter Review
This works based on my testing... I have a few more things to test, but going ahead and posting it for initial review.
Attachment #442604 - Attachment is obsolete: true
Attachment #442648 - Flags: review?(mkanat)
Attached patch patch - v1.1 (obsolete) — Splinter Review
Noticed I wasn't updating $bug->{lastdiffed} after changing it in the DB, so fixed that.

One thing I did notice is that Bugzilla::BugMail::create() and Bugzilla::BugMail::update() modify `delta_ts` directly in the DB for other bugs (dependent / blocking). What happens to bug objects that might already be in memory somehow with a (now) obsolete `delta_ts` field? ... or would that never happen / not be possible? Figured I'd mention it, at least...
Attachment #442648 - Attachment is obsolete: true
Attachment #442652 - Flags: review?(mkanat)
Attachment #442648 - Flags: review?(mkanat)
Comment on attachment 442652 [details] [diff] [review]
patch - v1.1

>+    my @fields = Bugzilla->get_fields({obsolete => 0});

One small optimization would be to add |in_new_bugmail => 1| to the get_fields() call, which would allow me to drop this check from a loop:

>+        foreach my $field (@fields) {
>+            # Skip if this field shouldn't be shown in new bugmail
>+            next unless $field->in_new_bugmail;
(In reply to comment #6)
> One thing I did notice is that Bugzilla::BugMail::create() and
> Bugzilla::BugMail::update() modify `delta_ts` directly in the DB for other bugs
> (dependent / blocking). What happens to bug objects that might already be in
> memory somehow with a (now) obsolete `delta_ts` field? ... or would that never
> happen / not be possible? Figured I'd mention it, at least...

  Those objects aren't re-used, so it's OK. There's no global cache of bug objects.
Attachment #442652 - Flags: review?(mkanat) → review+
Comment on attachment 442652 [details] [diff] [review]
patch - v1.1

This looks great. I'm really impressed with how awesome this patch is, actually. :-)
Flags: approval+
Keywords: relnote
Whiteboard: [relnote that "changer" must now be an object]
Attached patch what I landedSplinter Review
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/
modified attachment.cgi
modified editusers.cgi
modified email_in.pl
modified importxml.pl
modified post_bug.cgi
modified process_bug.cgi
modified sanitycheck.cgi
modified Bugzilla/Bug.pm
modified Bugzilla/BugMail.pm
modified Bugzilla/User.pm
modified Bugzilla/WebService/Bug.pm
modified contrib/sendbugmail.pl
modified extensions/Voting/Extension.pm
modified template/en/default/email/newchangedmail.txt.tmpl
Committed revision 7150.
Attachment #442652 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
After this change I started getting the follow error:

"in_new_bugmail is not a valid parameter for the Bugzilla::Field::match function."

What should be the problem?
(In reply to comment #11)
> After this change I started getting the follow error:
> 
> "in_new_bugmail is not a valid parameter for the Bugzilla::Field::match
> function."
> 
> What should be the problem?

When submitting a new bug, post_bug.cgi.
Blocks: 565145
Blocks: 583167
Blocks: 583287
Whiteboard: [relnote that "changer" must now be an object]
Added to the release notes in bug 604256.
Keywords: relnote
Keywords: relnote
Added to the release notes in bug 604256.
Keywords: relnote
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: