Change record status: 
Project: 
Introduced in branch: 
11.3.x
Introduced in version: 
11.3.0
Description: 

The theme_get_setting() method is deprecated. It has been replaced by a new Drupal\Core\Extension\ThemeSettingsProvider service.

Before

// Get a setting from 'bartik' theme.
$logo = theme_get_setting('logo.url', 'bartik');

// Clear the 'bartik' theme settings static cache.
$theme_settings = &drupal_static('theme_get_setting');
unset($theme_settings[$theme_name]);

// Clear the theme settings static cache for all themes.
drupal_static_reset('theme_get_setting');

After

// It's recommended to inject the service where possible. 
$themeSettingsProvider = \Drupal::service('Drupal\Core\Extension\ThemeSettingsProvider');

// Get a setting from 'bartik' theme.
$logo = $themeSettingsProvider->getSetting('logo.url', 'bartik');

// Clear the 'bartik' theme settings static cache.
\Drupal::service('cache.memory')->delete('theme_settings:bartik');

// Clear the theme settings static cache for all themes.
\Drupal::service('cache_tags.invalidator')->invalidateTags(['config:system.theme.global']);

Additionally, not passing the $themeSettingsProvider service to the Drupal\Core\Render\BareHtmlPageRenderer and Drupal\system\Plugin\Block\SystemBrandingBlock constructors is deprecated.

These parameters will be mandatory in Drupal 12.0.0.

Impacts: 
Module developers
Themers
Site templates, recipes and distribution developers

Comments

donquixote’s picture

The recommendation about clearing caches does not align with what was done in Drupal core tests.
https://git.drupalcode.org/project/drupal/-/commit/be276ecb985c282019f5c...

Core only invalidates tags, does not delete cache records:

    $this->assertEquals($expected, \Drupal::service(ThemeSettingsProvider::class)->getSetting('logo.url', 'stark'));

This change record deletes a cache record:

// Clear the 'bartik' theme settings static cache.
\Drupal::service('cache.memory')->delete('theme_settings:bartik');

I assume invalidating the cache tag would be enough.