Problem/Motivation

Unfortunately, we identified another issue with #3590050: Deprecate and replace locale_status related functions, existing sites have stored stdClass objects but we must now return LocaleTranslationSource

Steps to reproduce

Install in a multilingual site on 11.3, ensure you checked for translations at least once. Then update to 11.4

Proposed resolution

I think the easiest option is to just call \Drupal\locale\LocaleSource::clearSources() in a post update, so that the source information is rebuilt. This is non-persistent data, that's why that API exists, it's called automatically on the report page if the current data is old enough and some other cases too.

The alternative would be to convert from stdClass to LocaleTranslationSource but for all locale projects with a new version, we need to recalculate the information anyway.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3601433

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

berdir created an issue. See original summary.

berdir’s picture

Status: Active » Needs review

Created a merge request. Our filled database dump for 11.4 doesn't include locale source information, so to reproduce this problem in an update test, we'd need to manually create the expected data structures to be able to have a failing test. I hope we can skip that considering the code is pretty trivial and easy enough to test manually. Maybe a follow-up to improve test coverage around that?

While testing this with drush locale:check and drush locale:update, I noticed another issue, namely that \Drush\Commands\core\LocaleCommands::update() does in fact rely on locale_translation_get_status() loading the locale.translation.inc file, so the call to _locale_translation_default_update_options() then fails. Included that here as well.

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

This looks good. I think this qualifies as a fix without the test only.

Do we want a follow up where we add the translations to the fixtures?

I think we got most of the includes back in where they belong. I'll do another pass comparing 11.3 to 11.4 to make sure we captured all of the other automatic includes.

nicxvan’s picture

Status: Reviewed & tested by the community » Needs work

Ok I took another pass, I think we can address anything else in a follow up.

nicxvan’s picture

Status: Needs work » Reviewed & tested by the community

Let's get this in!

quietone’s picture

Title: TypeError: LocaleSource::loadSource(): Return value must be of type LocaleTranslationSource after updating to 11.4 » Fix local_status deprecation by clearing source in a post update

Trying for a descriptive title for the commit log.

berdir’s picture

@quietone: the commit message will be prefixed with "fix: ", no? So I usually the describe the problem/bug in the issue title and not the solution.

  • catch committed 3d876a6a on 11.4.x
    fix: #3601433 Fix local_status deprecation by clearing source in a post...

  • catch committed 561a957f on 11.x
    fix: #3601433 Fix local_status deprecation by clearing source in a post...

  • catch committed 7d0ebcd0 on main
    fix: #3601433 Fix local_status deprecation by clearing source in a post...
catch’s picture

Version: main » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to main, 11.x , and 11.4.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.