Skip to content

Commit 99457cc

Browse files
committed
Bug 986124 - backport upstream bug 513212 to bmo/4.2 to add the ability to add see_also values in enter_bug.cgi and Bug.create
1 parent 076af7d commit 99457cc

File tree

7 files changed

+64
-19
lines changed

7 files changed

+64
-19
lines changed

Bugzilla/Bug.pm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ sub create {
665665
my $blocked = delete $params->{blocked};
666666
my $keywords = delete $params->{keywords};
667667
my $creation_comment = delete $params->{comment};
668+
my $see_also = delete $params->{see_also};
668669

669670
# We don't want the bug to appear in the system until it's correctly
670671
# protected by groups.
@@ -727,6 +728,25 @@ sub create {
727728
}
728729
}
729730

731+
# Insert any see_also values
732+
if ($see_also) {
733+
my $see_also_array = $see_also;
734+
if (!ref $see_also_array) {
735+
$see_also = trim($see_also);
736+
$see_also_array = [ split(/[\s,]+/, $see_also) ];
737+
}
738+
foreach my $value (@$see_also_array) {
739+
$bug->add_see_also($value);
740+
}
741+
foreach my $see_also (@{ $bug->see_also }) {
742+
$see_also->insert_create_data($see_also);
743+
}
744+
foreach my $ref_bug (@{ $bug->{_update_ref_bugs} || [] }) {
745+
$ref_bug->update();
746+
}
747+
delete $bug->{_update_ref_bugs};
748+
}
749+
730750
# Comment #0 handling...
731751

732752
# We now have a bug id so we can fill this out

Bugzilla/WebService/Bug.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ sub create {
763763

764764
$dbh->bz_commit_transaction();
765765

766-
Bugzilla::BugMail::Send($bug->bug_id, { changer => $bug->reporter });
766+
$bug->send_changes();
767+
767768
return { id => $self->type('int', $bug->bug_id) };
768769
}
769770

enter_bug.cgi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ else {
314314
$vars->{'deadline'} = formvalue('deadline');
315315
$vars->{'estimated_time'} = formvalue('estimated_time');
316316
$vars->{'bug_ignored'} = formvalue('bug_ignored');
317+
$vars->{'see_also'} = formvalue('see_also');
317318

318319
$vars->{'cc'} = join(', ', $cgi->param('cc'));
319320

post_bug.cgi

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ use Bugzilla::Keyword;
4343
use Bugzilla::Token;
4444
use Bugzilla::Flag;
4545

46+
use List::MoreUtils qw(uniq);
47+
4648
my $user = Bugzilla->login(LOGIN_REQUIRED);
4749

4850
my $cgi = Bugzilla->cgi;
@@ -128,7 +130,7 @@ push(@bug_fields, qw(
128130
version
129131
target_milestone
130132
status_whiteboard
131-
133+
see_also
132134
estimated_time
133135
deadline
134136
));
@@ -239,12 +241,21 @@ my $bug_sent = Bugzilla::BugMail::Send($id, $recipients);
239241
$bug_sent->{type} = 'created';
240242
$bug_sent->{id} = $id;
241243
my @all_mail_results = ($bug_sent);
244+
242245
foreach my $dep (@{$bug->dependson || []}, @{$bug->blocked || []}) {
243246
my $dep_sent = Bugzilla::BugMail::Send($dep, $recipients);
244247
$dep_sent->{type} = 'dep';
245248
$dep_sent->{id} = $dep;
246249
push(@all_mail_results, $dep_sent);
247250
}
251+
252+
# Sending emails for any referenced bugs.
253+
foreach my $ref_bug_id (uniq @{ $bug->{see_also_changes} || [] }) {
254+
my $ref_sent = Bugzilla::BugMail::Send($ref_bug_id, $recipients);
255+
$ref_sent->{id} = $ref_bug_id;
256+
push(@all_mail_results, $ref_sent);
257+
}
258+
248259
$vars->{sentmail} = \@all_mail_results;
249260

250261
$format = $template->get_format("bug/create/created",

skins/standard/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ input.required, select.required, span.required_explanation {
546546
}
547547

548548
.bug_urls {
549-
margin: 0 0 1em 0;
549+
margin: 0;
550550
padding: 0;
551551
list-style-type: none;
552552
}

template/en/default/bug/create/create.html.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,17 @@ TUI_hide_default('attachment_text_field');
629629
%]
630630
</tr>
631631
[% END %]
632+
633+
[% IF Param('use_see_also') %]
634+
<tr>
635+
[% INCLUDE bug/field.html.tmpl
636+
bug = default
637+
field = bug_fields.see_also
638+
editable = 1
639+
value = see_also
640+
%]
641+
</tr>
642+
[% END %]
632643
</tbody>
633644

634645
<tbody>

template/en/default/bug/field.html.tmpl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,33 @@
204204
true);
205205
</script>
206206
[% CASE constants.FIELD_TYPE_BUG_URLS %]
207-
[% '<ul class="bug_urls">' IF value.size %]
208-
[% FOREACH bug_url = value %]
209-
<li>
210-
[% PROCESS bug_url_link bug_url = bug_url %]
211-
<label><input type="checkbox" value="[% bug_url.name FILTER html %]"
212-
name="remove_[% field.name FILTER html %]">
213-
Remove</label>
214-
</li>
207+
[% IF bug.id && value.size %]
208+
<ul class="bug_urls">
209+
[% FOREACH bug_url = value %]
210+
<li>
211+
[% PROCESS bug_url_link bug_url = bug_url %]
212+
<label><input type="checkbox" value="[% bug_url.name FILTER html %]"
213+
name="remove_[% field.name FILTER html %]">
214+
Remove</label>
215+
</li>
216+
[% END %]
217+
</ul>
215218
[% END %]
216-
[% '</ul>' IF value.size %]
217-
218219
[% IF Param('use_see_also') %]
219220
<span id="container_showhide_[% field.name FILTER html %]"
220221
class="bz_default_hidden">
221222
(<a href="#" id="showhide_[% field.name FILTER html %]">add</a>)
222223
</span>
223224
<div id="container_[% field.name FILTER html %]">
224-
<label for="[% field.name FILTER html %]">
225-
Add [% terms.Bug %] URLs:
226-
</label><br>
227225
<input type="text" id="[% field.name FILTER html %]" size="40"
228-
class="text_input" name="[% field.name FILTER html %]">
226+
class="text_input" name="[% field.name FILTER html %]"
227+
[% IF !bug.id %]value="[% value FILTER html %]"[% END %]>
229228
</div>
230-
<script type="text/javascript">
229+
[% IF bug.id %]
230+
<script type="text/javascript">
231231
setupEditLink('[% field.name FILTER js %]');
232-
</script>
232+
</script>
233+
[% END %]
233234
[% END %]
234235
[% CASE constants.FIELD_TYPE_KEYWORDS %]
235236
<div id="keyword_container">

0 commit comments

Comments
 (0)