Deprecate theme_get_setting()

Created on 23 February 2019, over 6 years ago
Updated 17 April 2025, 6 months ago

Currently blocked on:

Problem/Motivation

Reason #2999721: [META] Deprecate the legacy include files before Drupal 9 β†’ .

Proposed resolution

Deprecate theme_get_setting() and move its logic into ThemeHandlerInterface. Or a new service?

Remaining tasks

None.

User interface changes

None.

API changes

New methods in ThemeHandlerInterface:

  • ::getThemeSetting()
  • ::clearThemeSettingCache()

Data model changes

None.

Release notes snippet

N/A

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component

theme system

Created by

πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Merge request !11865Issue #3035288: Deprecate theme_get_setting β†’ (Open) created by acbramley
  • Pipeline finished with Failed
    6 months ago
    Total: 247s
    #475588
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Working on this, fixed #36

  • Pipeline finished with Success
    6 months ago
    Total: 338s
    #475594
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    I think the main thing here is the service/class name. Otherwise this looks good to go.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    With regards to the param types. Part of me wants to say yes lets do it and knock it out. But other part is concerned how much it could expand the scope?

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    no one else had a vote, lets give it a shot.

  • Pipeline finished with Success
    5 months ago
    Total: 678s
    #489639
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Done

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Believe that was the last bit.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    I think we should consider improving the architecture rather than injecting yet another service into the theme installer. I think we could even remove the clear cache method if we listen to configuration events.

  • Pipeline finished with Failed
    5 months ago
    Total: 234s
    #490821
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Improved the solution substantially with:

    1. Config subscriber as requesting by @alexpott to clear theme settings caches when core.extension:theme changes
    2. Memory cache service following recommendations in 🌱 [policy] Standardize how we implement in-memory caches Needs work

  • Pipeline finished with Success
    5 months ago
    Total: 1021s
    #490823
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Some things are missing in the CR and the proxy class likely needs to be regenerated.

    Also had a question on the new service.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Addressed feedback, service names are personal preference I guess? Personally not a huge fan of a class name service and interface name alias.

  • Pipeline finished with Failed
    5 months ago
    Total: 552s
    #490859
  • Pipeline finished with Success
    5 months ago
    Total: 439s
    #491772
  • Pipeline finished with Success
    4 months ago
    Total: 401s
    #534729
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Another review.

  • Pipeline finished with Failed
    3 months ago
    #541408
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Failed
    3 months ago
    #541412
  • Pipeline finished with Success
    3 months ago
    #541415
  • Pipeline finished with Success
    3 months ago
    Total: 465s
    #546630
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Pipeline finished with Success
    3 months ago
    Total: 1125s
    #547366
  • Pipeline finished with Failed
    3 months ago
    #550814
  • Pipeline finished with Success
    3 months ago
    #550819
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    @berdir wonder if some of the threads from you can be resolved?

  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. 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.

  • Pipeline finished with Success
    about 2 months ago
    Total: 682s
    #583621
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    This is very close, as far as I can tell the only remaining task is to move the event subscriber to the right namespace, core/ theme/ eventsubscriber.

  • Pipeline finished with Success
    about 1 month ago
    Total: 658s
    #588469
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Ok, I took another look through this and I think it's ready.

    There are three open comments on the MR still, but I think the answers address the concerns. I left them open in case others have a different opinion.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Added some review comments to the MR - we need to ensure uninstalled themes are removed from the memory cache too.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    I feel like this is a lot of complexity with that event subscriber, I'd suggest we do one of two things:

    a) As mentioned before, ThemeInstaller and ThemeSettingsProvider are in the same component. This is like a module implementing it's own hook/event. We could just do a 1:1 transformation and reset the static cache bin keys directly in ThemeInstaller.

    b) Add the core.extension cache tag to those cache entries. Yes, that will reset it on any module or theme install or uninstall completely. But we're talking about module/theme install (or well, weight changes, but how often do those happen?). I still think a any of those actions should just do a full cache reset. That logic is pretty much exclusively there for tests and edge case, I debugged ThemeInstaller when installing a theme through the UI and $theme_settings is NULL, it's going to be the same for drush and config import as well. There's nothing to reset in all regular cases.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    @berdir suggested using the core.extension cache tag and then we wouldn't need the listener at all. Makes sense to me.

  • Pipeline finished with Success
    about 1 month ago
    Total: 1308s
    #589441
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    I've removed the event subscriber and added the cache tag, IIUC that's all that is needed

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Like right to me, I'm going to give berdir and alexpott a chance to look since it was their concern and solution.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    This looks good to me as well.

    My proposal used a named argument, which I think is really neat in this case as we don't need to pass in the extra constant and have a use for that, but AFAIK, it's explicitly excluded by our BC policy, so not sure about that: https://www.drupal.org/about/core/policies/core-change-policies/bc-polic... β†’ . Leaving that to @alexpott.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    I think we're really close but when reviewing the code I realised we should add the cache tag info to the ThemeSettings object and use that. It'll nicely encapsulate the tags required for the memory cache.

    Also we're missing a BC layer for drupal_static_reset('theme_get_setting');. The drupal_static() usage is a little more tricky. Not sure what to do about that.

    Also adding cache.memory here is interesting. For other memory caches we've done stuff like

      # Set up a cache chain for asset caching as the same assets may be
      # requested several times, non-public as they are not meant to be reused.
      cache.asset_memory:
        class: Drupal\Core\Cache\MemoryCache\MemoryCache
        arguments: ['@datetime.time']
        public: false
    

    and

      system.module_admin_links_memory_cache:
        class: Drupal\Core\Cache\MemoryCache\MemoryCache
        arguments: ['@datetime.time']
    

    Should we really be adding a generic one? I'm not sure about that.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Obviously something that is interesting about the memory cache backend adding for assets and admin links is that I suspect their entries are not covered by the cache tag invalidator...

    So perhaps all that needs changing here is that cache.memory should become a more specific name... inline with

      cache.access_policy_memory:
        class: Drupal\Core\Cache\CacheBackendInterface
        tags:
          - { name: cache.bin.memory, default_backend: cache.backend.memory.memory }
        factory: ['@cache_factory', 'get']
        arguments: [access_policy_memory]
    
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Since alexpott detected my attempts to sneak in the cache.memory bin, we agreed in Slack to revive 🌱 [policy] Standardize how we implement in-memory caches Needs work and pull that bit out. It's an old issue, but we essentially already did what was originally proposed there, so it _should_ be simpler.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Sounds like we need to postpone this issue then?

  • Pipeline finished with Failed
    about 1 month ago
    Total: 219s
    #590505
  • Pipeline finished with Success
    about 1 month ago
    #590512
Production build 0.71.5 2024