diff options
author | Simon Green <sgreen@redhat.com> | 2014-08-14 09:40:47 +1000 |
---|---|---|
committer | Simon Green <sgreen@redhat.com> | 2014-08-14 09:40:47 +1000 |
commit | 424b21e37cd9aeac01588ce0defd3ee665944b1d (patch) | |
tree | 594aa91a4fafc7c30d26e0ee9a160f62bf4d063f /Bugzilla/WebService | |
parent | 6dbcec07eba4b0910c883141a85b0b9928b85f32 (diff) | |
download | bugs-424b21e37cd9aeac01588ce0defd3ee665944b1d.tar bugs-424b21e37cd9aeac01588ce0defd3ee665944b1d.tar.gz bugs-424b21e37cd9aeac01588ce0defd3ee665944b1d.tar.bz2 bugs-424b21e37cd9aeac01588ce0defd3ee665944b1d.tar.xz bugs-424b21e37cd9aeac01588ce0defd3ee665944b1d.zip |
Bug 1012506 - Allow a bug to have multiple aliases
r=dkl, a=sgreen
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r-- | Bugzilla/WebService/Bug.pm | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 4689ae0f2..334be1057 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -468,7 +468,7 @@ sub history { # alias is returned in case users passes a mixture of ids and aliases # then they get to know which bug activity relates to which value # they passed - $item{alias} = $self->type('string', $bug->alias); + $item{alias} = [ map { $self->type('string', $_) } @{ $bug->alias } ]; push(@return, \%item); } @@ -632,6 +632,16 @@ sub update { # called using those field names. delete $values{dependencies}; + # For backwards compatibility, treat alias string or array as a set action + if (exists $values{alias}) { + if (not ref $values{alias}) { + $values{alias} = { set => [ $values{alias} ] }; + } + elsif (ref $values{alias} eq 'ARRAY') { + $values{alias} = { set => $values{alias} }; + } + } + my $flags = delete $values{flags}; foreach my $bug (@bugs) { @@ -669,7 +679,7 @@ sub update { # alias is returned in case users pass a mixture of ids and aliases, # so that they can know which set of changes relates to which value # they passed. - $hash{alias} = $self->type('string', $bug->alias); + $hash{alias} = [ map { $self->type('string', $_) } @{ $bug->alias } ]; my %changes = %{ $all_changes{$bug->id} }; foreach my $field (keys %changes) { @@ -1163,7 +1173,6 @@ sub _bug_to_hash { # A bug attribute is "basic" if it doesn't require an additional # database call to get the info. my %item = %{ filter $params, { - alias => $self->type('string', $bug->alias), creation_time => $self->type('dateTime', $bug->creation_ts), # No need to format $bug->deadline specially, because Bugzilla::Bug # already does it for us. @@ -1187,6 +1196,9 @@ sub _bug_to_hash { # First we handle any fields that require extra SQL calls. # We don't do the SQL calls at all if the filter would just # eliminate them anyway. + if (filter_wants $params, 'alias') { + $item{alias} = [ map { $self->type('string', $_) } @{ $bug->alias } ]; + } if (filter_wants $params, 'assigned_to') { $item{'assigned_to'} = $self->type('email', $bug->assigned_to->login); $item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to'); @@ -2168,7 +2180,8 @@ in the return value. =item C<alias> -C<string> The unique alias of this bug. +C<array> of C<string>s The unique aliases of this bug. An empty array will be +returned if this bug has no aliases. =item C<assigned_to> @@ -2613,7 +2626,8 @@ C<int> The numeric id of the bug. =item alias -C<string> The alias of this bug. If there is no alias, this will be undef. +C<array> of C<string>s The unique aliases of this bug. An empty array will be +returned if this bug has no aliases. =item history @@ -2796,7 +2810,8 @@ just reuse the query parameter portion in the REST call itself. =item C<alias> -C<string> The unique alias for this bug. +C<array> of C<string>s The unique aliases of this bug. An empty array will be +returned if this bug has no aliases. =item C<assigned_to> @@ -3053,7 +3068,7 @@ in by the developer, compared to the developer's other bugs. =item C<severity> (string) B<Defaulted> - How severe the bug is. -=item C<alias> (string) - A brief alias for the bug that can be used +=item C<alias> (array) - A brief alias for the bug that can be used instead of a bug number when accessing this bug. Must be unique in all of this Bugzilla. @@ -3754,9 +3769,29 @@ bugs you are updating. =item C<alias> -(string) The alias of the bug. You can only set this if you are modifying -a single bug. If there is more than one bug specified in C<ids>, passing in -a value for C<alias> will cause an error to be thrown. +C<hash> These specify the aliases of a bug that can be used instead of a bug +number when acessing this bug. To set these, you should pass a hash as the +value. The hash may contain the following fields: + +=over + +=item C<add> An array of C<string>s. Aliases to add to this field. + +=item C<remove> An array of C<string>s. Aliases to remove from this field. +If the aliases are not already in the field, they will be ignored. + +=item C<set> An array of C<string>s. An exact set of aliases to set this +field to, overriding the current value. If you specify C<set>, then C<add> +and C<remove> will be ignored. + +=back + +You can only set this if you are modifying a single bug. If there is more +than one bug specified in C<ids>, passing in a value for C<alias> will cause +an error to be thrown. + +For backwards compatibility, you can also specify a single string. This will +be treated as if you specified the set key above. =item C<assigned_to> @@ -4075,7 +4110,8 @@ C<int> The id of the bug that was updated. =item C<alias> -C<string> The alias of the bug that was updated, if this bug has an alias. +C<array> of C<string>s The aliases of the bug that was updated, if this bug +has any alias. =item C<last_change_time> @@ -4109,7 +4145,7 @@ Here's an example of what a return value might look like: bugs => [ { id => 123, - alias => 'foo', + alias => [ 'foo' ], last_change_time => '2010-01-01T12:34:56', changes => { status => { |