Skip to content

Fix getID method to handle null values and always return a string#77

Merged
derpixler merged 1 commit into
zammad:masterfrom
Axiome974:patch-1
Jun 8, 2026
Merged

Fix getID method to handle null values and always return a string#77
derpixler merged 1 commit into
zammad:masterfrom
Axiome974:patch-1

Conversation

@Axiome974

Copy link
Copy Markdown
Contributor

getID() should always return a string, but in some cases it returns an integer.

getID() should always return a string, but in some cases it returns an integer.
@derpixler

Copy link
Copy Markdown
Contributor

@Axiome974 Thanks for the PR! The fix looks good -- the explicit (string) cast and null check solve the type inconsistency from json_decode() where IDs come back as integers.

Two small suggestions:

  1. Please update the docblock to @return string|null since the method now explicitly returns null for unsaved objects.
  2. Consider adding a simple test for getID() (e.g., returns null for an unsaved object, returns a string after fetch).

@derpixler derpixler merged commit 4405eb6 into zammad:master Jun 8, 2026
derpixler added a commit that referenced this pull request Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants