Problem/Motivation

locale_translation_clear_cache_projects() tries to clear the the locale_translation_get_projects drupal_static() cache, but does so incorrectly.

This surfaces when installing Drupal via Drush in a different language. Initially the list of projects to install translations for contains only drupal. When later importing translations for other projects, the now stale list is retrieved instead of recalculating the list of projects based on the modules that have been enabled as part of the installation.

When installing through the UI this does not surface because - as always - each installation step is performed in a separate request, thus, the static is irrelevant.

Proposed resolution

Call drupal_static_reset() from locale_translation_clear_cache_projects().

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

Status: Active » Needs review
FileSize
517 bytes

Here we go.

As usual, this whole code path is so convoluted that there is no way to write tests for this. :-/

I also wondered whether there is any value at all in the static, but let's fix the bleeding first.

Status: Needs review » Needs work

The last submitted patch, 1: 2361415-1.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
537 bytes

Today is just not my day.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Meh, I guess there is also no way to test that?

tstoeckler’s picture

I genuinely thought about how to test this, but I have no clue whatsoever. I'm fairly certain it can't be done.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Surely this is testable by doing soemthing like

$projects = &drupal_static('locale_translation_get_projects', array());
$projects['test'] = 'test';
locale_translation_clear_cache_projects();
$this->assertEqual(array(), $projects);
tstoeckler’s picture

Assigned: Unassigned » tstoeckler

Ahh, yes that would be possible. I thought about triggering the actual symptom described in the issue summary from within a test.

Yes, will write a little KernelTestBase.

tstoeckler’s picture

Assigned: tstoeckler » Unassigned
Status: Needs work » Needs review
FileSize
1.87 KB
2.39 KB

Here we go.

The last submitted patch, 8: 2361415-8-test-only.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +D8MI, +language-ui, +sprint

The test looks great on a textual review. The bug is #facepalm.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5dcc99f and pushed to 8.0.x. Thanks!

  • alexpott committed 5dcc99f on 8.0.x
    Issue #2361415 by tstoeckler: Fixed...

Status: Fixed » Needs work

The last submitted patch, 8: 2361415-8-pass.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
2.39 KB

So this got stuck on a testbot twice. Re-uploading to see if the same happens when it (hopefully) gets fetched by a different bot.

tstoeckler’s picture

Status: Reviewed & tested by the community » Fixed

Hey, that's nice! :-)

Status: Fixed » Needs work

The last submitted patch, 14: 2361415-8-pass.patch, failed testing.

alexpott’s picture

Status: Needs work » Fixed

I confirmed that Drupal\locale\Tests\LocaleTranslationProjectsTest was green before committing and 1 liner was already green :)

Gábor Hojtsy’s picture

Issue tags: -sprint

Superb, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.