locale_language_save() introduced in #1215716: Introduce locale_language_save() clears the following caches:

  // Kill the static cache in language_list().
  drupal_static_reset('language_list');

  // Changing the language settings impacts the interface.
  cache_clear_all('*', 'cache_page', TRUE);

  // Force JavaScript translation file re-creation for the modified language.
  _locale_invalidate_js($language->language);

The last two are not desired in the API function and since we have not been able to find a good abstract place for these two to live in locale module, @catch asked me to open a separate issue to continue figure this out. Here it is.

Comments

catch’s picture

Background to this is issues like #757484: Optimize node_save() where we tried to decouple API CRUD functions from clearing the page and block caches (for example you might want to add 300 languages at once in an import, then clear the page cache once at the end).

The tricky bit here is the js invalidation, I'm not at all sure which category this falls into.

Also wondered why this is clearing the page cache rather than calling cache_clear_all() (no arguments) to affect cached HTML in the block cache.

gábor hojtsy’s picture

What happens when a language is added or changed can be an intricate question. If I change the name or direction of my language, that would invalidate some page caches (all where this language was used or referenced by name) and some block caches (for language switcher blocks for example where the language is possibly referenced by name). If I only change the order of the languages or the default language, that might invalidate all page caches (it changes order of languages in the language switcher block and might change which language shows up under which URL depending on language negotiation settings). Or it might not change anything at all if I'm not showing a language switcher block and I have a negotiation configuration that uses data independent of the language order (such as session information, which is in itself might not be page cache compatible).

I think its safe to assume that most language changes / additions will need to clear page/block caches under the most common language negotiation configurations and that is probably the closest we have to define what/when is needed to be cleared.

gábor hojtsy’s picture

Title: locale_language_save() should only have local cache side effects » language_save() should only have local cache side effects
Issue tags: +language-base

Tagging for base language system. Also retitling for changed function name.

gábor hojtsy’s picture

Title: language_save() should only have local cache side effects » locale_language_insert() and locale_language_update() should only have local cache side effects
Issue tags: -language-base +language-ui

In fact language_save() will not do that update anymore now that locale (UI translation) and language is separated. The following functions do the cleanup in expectation that it changes pages likely with locale module there.

http://api.drupal.org/api/drupal/core--modules--locale--locale.module/fu...
http://api.drupal.org/api/drupal/core--modules--locale--locale.module/fu...

Moving to the UI translation subspace due to that.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Believe this is no longer needed as language_save() has been removed https://www.drupal.org/node/2336669

If still a valid task though please reopen and update issue summary for D10

Thanks

berdir’s picture

Status: Closed (outdated) » Active

Re-opening this, the todo to this issue still exists in \Drupal\locale\Hook\LocaleHooks::configurableLanguageInsert() and \Drupal\locale\Hook\LocaleHooks::configurableLanguageUpdate(), the code is still there, it was just moved.

what we should at least do:

* switch to a render cache tag invalidation, much faster (on DB anyway) and covers all render caches. If we even need that. Because at least
* adding a new language should _not_ affect existing caches, except a few things that explicitly list languages like the language switcher?
* merge the two hooks together
* remove the todo if there's really nothing left to do

berdir’s picture

Version: 9.5.x-dev » main