Skip to content

Conversation

kjkooistra-youwe
Copy link
Contributor

@kjkooistra-youwe kjkooistra-youwe commented Apr 17, 2025

Pimcore\Translation\Translator::trans(): Argument #1 ($id) must be of type string, null given
Fixed by adding a condition to check whether abbreviation is null and using the untranslated ID instead.

To reproduce, set a quantity value with a unit without an abbreviation. This unit would be created via the PHP API.

Encountered this error in the messenger failed queue of an import because it creates units for use in the Pimcore, but it doesn't provide any additional details (like abbreviation).

Copy link

Review Checklist

  • Target branch (11.5 for bug fixes, others 11.x)
  • Tests (if it's testable code, there should be a test for it - get help)
  • Docs (every functionality needs to be documented, see here)
  • Migration incl. install.sql (e.g. if the database schema changes, ...)
  • Upgrade notes (deprecations, important information, migration hints, ...)
  • Label
  • Milestone

@jdreesen
Copy link
Contributor

Note that #18313 wants to change the same line.

@ghost ghost added the Pimcore:ToDo label Apr 28, 2025
Pimcore\Translation\Translator::trans(): Argument #1 ($id) must be of type string, null given
Fixed by adding a condition to check whether abbreviation is null and using the untranslated ID instead.
Copy link

sonarqubecloud bot commented May 9, 2025

@robertSt7 robertSt7 self-assigned this Aug 13, 2025
@robertSt7
Copy link
Contributor

@kjkooistra-youwe I am not able to save a unit with null in abbreviation. For me the abbreviation is always an empty string, even when I export it, write null as value and import it. Could you please provide more information? Thanks

@kjkooistra-youwe
Copy link
Contributor Author

kjkooistra-youwe commented Aug 13, 2025

@robertSt7 The units were created by an import via the PHP API. If the abbreviation is not set there it's null. I updated the initial comment to clarify this.

protected ?string $abbreviation = null;

@robertSt7 robertSt7 added this to the 11.5.9 milestone Aug 26, 2025
@robertSt7 robertSt7 merged commit ba44ee4 into pimcore:11.5 Aug 26, 2025
19 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2025
@robertSt7
Copy link
Contributor

@kjkooistra-youwe Thanks for fixing this null error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants