php-JiraCloud-RESTAPI icon indicating copy to clipboard operation
php-JiraCloud-RESTAPI copied to clipboard

Transition by untranslated name not working properly

Open brutto opened this issue 1 year ago • 1 comments

It is not duplication of https://github.com/lesstif/php-JiraCloud-RESTAPI/issues/15. Problem still exists. @lesstif

Previous issue was fixed partly: only for code syntax, not logic.

In doc for issue transition was said to use Transition::setUntranslatedName() method for "JIRA with local language profiles".

But if you use it transition id calculated wrong. Instead of transition id used status id. So you get errors like {"errorMessages":["Transition id '' is not valid for this issue."],"errors":{}}.

Problem in IssueService::findTransitonIdByUntranslatedName.

        foreach ($transitionArray as $trans) {
            if (strcasecmp($trans['name'], $untranslatedName) === 0 ||
                strcasecmp($trans['untranslatedName'] ?? '', $untranslatedName) === 0) {
                return $trans['id']; // <-- here
            }
        }

The core problem is about using status id instead of using transition id. My workaround is (its not perfect and can be improved):

        foreach ($transitionArray as $trans) {
            if (strcasecmp($trans['name'], $untranslatedName) === 0 ||
                strcasecmp($trans['untranslatedName'] ?? '', $untranslatedName) === 0) {
                return $this->findTransitonId($issueIdOrKey, $trans['name']); /// <-- this is correct logic
            }
        }

brutto avatar Nov 07 '22 10:11 brutto