Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate all Redmine\Api\*::getIdByName() methods #417

Closed
Art4 opened this issue Jul 5, 2024 · 0 comments · Fixed by #422
Closed

Deprecate all Redmine\Api\*::getIdByName() methods #417

Art4 opened this issue Jul 5, 2024 · 0 comments · Fixed by #422
Assignees
Milestone

Comments

@Art4
Copy link
Collaborator

Art4 commented Jul 5, 2024

In #338 we have deprecated all listing() methods. These methods are the base for the getIdByName() methods.

Getting the ID by a name could easily made by using the new listNames() methods and array_search().

$name = 'Feature';

/** @var int|false */
- $id = $client->getApi('tracker')->getIdByName($name);
+ $id = array_search($name, $client->getApi('tracker')->listNames(), true);

However, some endpoints allow name duplications (e.g. projects and versions), so it might become difficult to decide witch ID should be chosen on a name collision.

Instead of editing this methods (to use the listNames() methods internally) and made prediction about name collisions I propose to deprecated them and let the user handle this situation.

Affected methods

  • CustomField::getIdByName()
  • IssueCategory::getIdByName()
  • IssueStatus::getIdByName()
  • Project::getIdByName()
  • TimeEntryActivity::getIdByName()
  • Tracker::getIdByName()
  • User::getIdByUsername()
  • Version::getIdByName()
@Art4 Art4 added pending: help wanted help and PRs are welcome code quality labels Jul 5, 2024
@Art4 Art4 added this to the v2.7.0 milestone Jul 5, 2024
@Art4 Art4 changed the title Deprecate all getIdByName() methods Deprecate all Redmine\Api\*::getIdByName() methods Jul 5, 2024
@Art4 Art4 self-assigned this Jul 8, 2024
@Art4 Art4 removed the pending: help wanted help and PRs are welcome label Jul 8, 2024
@Art4 Art4 closed this as completed in #422 Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant