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

drupal-graphql#1322: Fix fatal error when attempting to load an entity for a language the entity is not translated into. #1388

Open
wants to merge 1 commit into
base: 8.x-4.x
Choose a base branch
from

Conversation

vermario
Copy link

If an entity is requested directly with a translation that it does not yet have, currently we see a fatal error, because the code tries to load the entity translation before checking for its existence.

This was noted by @artemvd in #1322.

The PR that was created #1323 didn't fix the issue in two additional plugins, this PR does, by adding the same code.

…ty for a language the entity is not translated into.

 This same pattern happens in three plugins, this fixes in all of them.
@almunnings
Copy link
Contributor

almunnings commented Jan 17, 2024

Does it need to return NULL?

Just wrapping the getTranslation with hasTranslation might be the desired outcome, with a fallback to default content.

Edit: Nevermind, I just read the linked PR from previous conversation. Allll good.

@klausi
Copy link
Contributor

klausi commented Mar 21, 2024

I think this makes sense. I was thinking if we need to add cache information before returning NULL, but since it should vary per language parameter anyway I think this is fine.

Can you add a test case to cover this?

@smavri-axess
Copy link

It's missing also the fix in the DataProducer TaxonomyLoadTree.

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

Successfully merging this pull request may close these issues.

None yet

4 participants