Skip to content

Commit

Permalink
Add missing tag name in error message
Browse files Browse the repository at this point in the history
When creating a new issue via REST API with a non-existing tag name,
the error message generated by mci_tag_set_for_issue() did not include
the tag's name.

This was caused by reusing the $t_tag variable to store the return value
of tag_get_by_name(), so the original data is no longer available when
the exception is thrown.

Same problem in IssueAddCommand::validate() if the user attempting to
create the issue does not have the required privileges to create tags,
this time due to usage of an uninitialized variable.

Fixes #25996
  • Loading branch information
dregad committed Aug 23, 2019
1 parent f1c84e1 commit f2756da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions api/soap/mc_tag_api.php
Expand Up @@ -167,15 +167,15 @@ function mci_tag_set_for_issue ( $p_issue_id, array $p_tags, $p_user_id ) {
);
}
} else if( isset( $t_tag['name'] ) ) {
$t_tag = tag_get_by_name( $t_tag['name'] );
if( $t_tag === false ) {
$t_get_tag = tag_get_by_name( $t_tag['name'] );
if( $t_get_tag === false ) {
throw new ClientException(
"Tag {$t_tag['name']} not found.",
"Tag '{$t_tag['name']}' not found.",
ERROR_TAG_NOT_FOUND
);
}

$t_tag_id = $t_tag['id'];
$t_tag_id = $t_get_tag['id'];
} else {
throw new ClientException(
'Tag without id or name.',
Expand Down
2 changes: 1 addition & 1 deletion core/commands/IssueAddCommand.php
Expand Up @@ -221,7 +221,7 @@ function validate() {
foreach( $t_issue['tags'] as $t_tag ) {
if( $t_tag['id'] === -1 ) {
throw new ClientException(
sprintf( "User '%d' can't create tag '%s'.", $this->user_id, $t_new_tag ),
sprintf( "User '%d' can't create tag '%s'.", $this->user_id, $t_tag['name'] ),
ERROR_TAG_NOT_FOUND );
}
}
Expand Down

0 comments on commit f2756da

Please sign in to comment.