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.

Issue fork drupal-3422895

Command icon 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

joachim created an issue. See original summary.

jackwrfuller made their first commit to this issue’s fork.

jackwrfuller’s picture

Modified both function's docs to specify that if there is no config override for the specified language code, a new one is instantiated.

jackwrfuller’s picture

Status: Active » Needs review
Issue tags: +DrupalSouth 2024
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Thanks for working on this!

Left a comment on the MR. Since the comment is related to the langCode, description should go under that variable.

charlliequadros’s picture

Status: Needs work » Needs review

Is anything else needed for this issue?
I'd be happy to work on it if necessary!

smustgrave’s picture

Status: Needs review » Needs work

Good practice issue summary should be complete

peter majmesku made their first commit to this issue’s fork.

jepster_’s picture

Status: Needs work » Reviewed & tested by the community

Looks fine. I fixed spelling. Improved the explanation and line breaks. Can this small change could be merged, please?

smustgrave’s picture

Status: Reviewed & tested by the community » Needs work

There 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

jepster_’s picture

I could not push into the existing MR. Even with requested push access. What do you mean with issue summary?

joachim’s picture

I 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'

  public function getOverride($langcode, $name) {
    $storage = $this->getStorage($langcode);
    $data = $storage->read($name);

    $override = new LanguageConfigOverride(
      $name,
      $storage,
      $this->typedConfigManager,
      $this->eventDispatcher
    );

    if (!empty($data)) {
      $override->initWithData($data);
    }
    return $override;
  }
charlliequadros’s picture

Status: Needs work » Needs review

Hi 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.

lavanyatalwar’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Issue summary needs to be updated

shubham_pareek_19’s picture

Issue summary: View changes
shubham_pareek_19’s picture

Status: Needs work » Needs review
Issue tags: -Needs issue summary update

I have updated the IS. Please review

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.77 KB

The 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.

nexusnovaz made their first commit to this issue’s fork.

nexusnovaz’s picture

Status: Needs work » Needs review

I've updated both branches to hopefully pass review bot. Please can we review?

smustgrave’s picture

Status: Needs review » Needs work

There are 2 MRs not clear what is to review

rodrigoaguilera changed the visibility of the branch 3422895-configurablelanguagemanagerinterfacegetlanguageconfigoverride-and-languageconfigfactoryoverrideinterfacegetoverride to hidden.

rodrigoaguilera’s picture

Status: Needs work » Needs review
Issue tags: +Vienna2025

Both 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!

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Nara2025

I 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!

skifdesu’s picture

We are working on it in DrupalCon Nara Contrib Day 2025.

murz’s picture

Mentoring on it at the DrupalCon Nara Contrib Day 2025.

skifdesu’s picture

Updated the documentations for the getting the Language override objects methods.

Please review the new changes. I will update the status to Needs review.

skifdesu’s picture

Status: Needs work » Needs review
joachim’s picture

Status: Needs review » Needs work

I 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?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

skifdesu’s picture

Status: Needs work » Needs review

> > 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:

  /**
   * @return \Drupal\language\Config\LanguageConfigOverride
   *   The language config override object for the requested $langcode. An
   *   object is always returned: $langcode and $name are not validated, so the
   *   object is empty when there is no override data for the given $name in the
   *   given $langcode. This includes the cases where the configuration has no
   *   override for that language, where $langcode is for a language that is not
   *   installed or does not exist, and where $name is not an existing
   *   configuration object.
   */
joachim’s picture

Status: Needs review » Needs work

> * The language configuration object name.

I thought this method was for working with any config. What's this about?