Problem/Motivation
The methods ConfigurableLanguageManagerInterface::getLanguageConfigOverride() and LanguageConfigFactoryOverrideInterface::getOverride() (which calls the former) return a config override object.
However, the current documentation does not mention that these methods always return a LanguageConfigOverride object — even if there is no existing override configuration for the given $langcode.
In such cases, the object returned will simply be empty (i.e., not initialized with any override data).
This behavior can be confusing if not explicitly documented.
Steps to reproduce
Call getOverride() or getLanguageConfigOverride() with a $langcode and config name for which no override exists. An object is still returned, but it contains no override data.
Proposed resolution
Update the PHPDoc for both methods to indicate that:
A LanguageConfigOverride object is always created and returned.
If no override data exists, the object is empty.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Clarified the PHPDoc for ConfigurableLanguageManagerInterface::getLanguageConfigOverride() and LanguageConfigFactoryOverrideInterface::getOverride() to state that a config override object is always returned — even if there is no override data.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3422895
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
jackwrfuller commentedModified both function's docs to specify that if there is no config override for the specified language code, a new one is instantiated.
Comment #5
jackwrfuller commentedComment #6
smustgrave commentedThanks for working on this!
Left a comment on the MR. Since the comment is related to the langCode, description should go under that variable.
Comment #7
charlliequadros commentedIs anything else needed for this issue?
I'd be happy to work on it if necessary!
Comment #8
smustgrave commentedGood practice issue summary should be complete
Comment #11
jepster_Looks fine. I fixed spelling. Improved the explanation and line breaks. Can this small change could be merged, please?
Comment #12
smustgrave commentedThere was already a working MR can we use that one please
Also it was in NW for an issue summary update which is still needed
Thanks
Comment #13
jepster_I could not push into the existing MR. Even with requested push access. What do you mean with issue summary?
Comment #14
joachim commentedI think what I originally wrote for this issue is unclear.
What I was trying to say was that one of the following happen:
1. There is config data already: a LanguageConfigOverride object is created, which holds this data
2. There is no config data: a LanguageConfigOverride is created anyway, which is empty.
So it's not so much that 'if there's no data, an object is created', rather 'an object is always created; if there's no data it will be empty'
Comment #15
charlliequadros commentedHi Everyone
I’ve improved the comment as joachim suggested.
Could someone please review this MR and let me know if anything else needs to be done?
I made changes in both MRs, but I’m not sure which one is the correct one to merge when it's ready.
Comment #16
lavanyatalwar commentedIssue summary needs to be updated
Comment #17
shubham_pareek_19 commentedComment #18
shubham_pareek_19 commentedI have updated the IS. Please review
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #21
nexusnovaz commentedI've updated both branches to hopefully pass review bot. Please can we review?
Comment #22
smustgrave commentedThere are 2 MRs not clear what is to review
Comment #24
rodrigoaguileraBoth MRs were the same so I hid the one with the lowest id. Rebased and now the tests are green, back to needs review. I think is still a good issue for a novice to review.
The Drupal Contribution Mentoring team is triaging issues for Drupalcon Vienna, and we are reserving this issue for Mentored Contribution during the event.
After October 17th, this issue returns to being open to all. Thanks!
Comment #25
xjmI posted some feedback on the merge request that could be addressed by a first-time contributor. I recommend carefully reviewing the issue summary, #14, and the APIs in question to understand what needs to be documented here, and updating the documentation accordingly. Thanks!
The Drupal Contribution Mentoring team is triaging issues for DrupalCon Nara 2025, and we are reserving this issue for Mentored Contribution during the event.
After November 19, this issue returns to being open to all. Thanks!
Comment #26
skifdesu commentedWe are working on it in DrupalCon Nara Contrib Day 2025.
Comment #27
murzMentoring on it at the DrupalCon Nara Contrib Day 2025.
Comment #28
skifdesu commentedUpdated the documentations for the getting the Language override objects methods.
Please review the new changes. I will update the status to Needs review.
Comment #29
skifdesu commentedComment #30
joachim commentedI feel I'm nitpicking, but starting the @return with
> The language config override object is always instantiated for the requested $langcode.
doesn't read right.
The @return usually starts with a noun phrase describing what is returned. Sentences after that add detail and context. Something like:
> The language config override object for the requested $langcode. If no configuration data exists, the object will be empty.
Also, I am confused about what we mean by 'no configuration data'.
In the IS, it says (possibly written by me!) --
> even if there is no existing override configuration for the given $langcode.
What are the possible causes of an empty return? Is it just if there is no translation? What happens if I requested a language that's not installed? Or a config name that's fictional? Does the empty object happen in all these cases?
Comment #32
skifdesu commented> > even if there is no existing override configuration for the given $langcode.
> What are the possible causes of an empty return? Is it just if there is no translation? What happens if I requested a language that's not installed? Or a config name that's fictional? Does the empty object happen in all these cases?
- LanguageConfigFactoryOverride::getOverride() builds a storage collection from the langcode with no validation, reads $name, and always returns a LanguageConfigOverride — only populating it when non-empty data exists.
- ConfigurableLanguageManager::getLanguageConfigOverride() just delegates to it.
So the description will look something like this:
Comment #33
joachim commented> * The language configuration object name.
I thought this method was for working with any config. What's this about?