Problem/Motivation
Now that hooks can be oop and in their own file there is no need for theme-settings.php
Let's convert all but the one test and deprecate this file.
Steps to reproduce
N/A
Proposed resolution
There are only two remaining.
Olivero
A test theme
Let's leave the test theme for legacy tests
Let's convert olivero to it's own oop hook class
Let's deprecate the file if it is found in theme hook collector pass.
For the legacy ignore deprecations also add a comment that we need to just convert the file when we drop support.
Remaining tasks
Review
User interface changes
N/A
Introduced terminology
N/A
API changes
theme-settings.php are no longer supported.
Data model changes
N/A
Release notes snippet
N/A
Comments
Comment #2
nicxvan commentedComment #3
nicxvan commentedComment #4
debdeep.mukhopadhyay commentedI am working on this.
Comment #6
debdeep.mukhopadhyay commentedHi @nicxvan,
I worked on the issue related to deprecating theme-settings.php in the Olivero theme.
While setting up the issue fork on Drupal 12.x-dev, I faced some dependency and environment related conflicts which made it difficult to properly test the theme settings behaviour. To avoid blocking progress, I recreated the setup on a stable Drupal 11 environment and verified the approach there.
I moved the logic from theme-settings.php to a new OOP hook class (OliveroThemeSettingsHooks) using the Hook attribute, registered it via olivero.services.yml, removed the legacy file, rebuilt cache, and confirmed that the Olivero appearance settings page loads and saves correctly without errors.
Now I am continuing the work on the issue fork branch to prepare a Drupal 12 compatible patch/MR.
Please let me know if anything else needs to be validated before I proceed further.
Thanks.
Comment #7
rajivgandhi chinnakrishnan commentedConverts olivero/theme-settings.php to an OOP hook class (ThemeSettingsHooks) using the #[Hook] attribute, then deletes the procedural file. A deprecation notice (E_USER_DEPRECATED) is added to HookCollectorPass so any contrib or custom theme still shipping a theme-settings.php gets a clear, actionable warning on container rebuild. The theme_test theme's file is intentionally left untouched to preserve legacy test coverage.
Comment #8
nicxvan commented@debdeep.mukhopadhyay thank you, I'm not sure what you mean about 11.x, the MR you posted is against main which is what will become drupal 12 so I think it is correct.
That conversion is correct, we do need to do the actual deprecation.
We do not need the services file for the theme, in fact it does nothing so we should delete it.
For the deprecation it should happen in ThemeHookCollectorPass around line 224, if $isThemeSettings is TRUE I would output a deprecation message.
This issue will need a CR explaining the changes as well.
Edited to add: We also need to resolve the PHPCS errors:
@rajivgandhi chinnakrishnan we don't use patches any longer for core contributions. I am going to hide it.
Also that patch has several issues with it so please don't push it to the MR without discussion.
Briefly, it's the wrong collectorPass, it mentions a drupal version no longer supported, I have no idea what version of core it's against since the olivero theme-settings don't seem to align with 11 or main.
Comment #9
debdeep.mukhopadhyay commentedHi @nicxvan, @rajivgandhi chinnakrishnan,
Thank you for the guidance and review comments.
After the last feedback, I re-verified the implementation by testing the OOP conversion of theme-settings.php in both Drupal 11 (for behaviour comparison) and current main (future Drupal 12). I also updated the approach based on suggestions — removing the unnecessary services.yml, addressing PHPCS feedback, and ensuring the deprecation logic is placed in the correct compiler pass (ThemeHookCollectorPass).
The changes are now aligned with the current core structure and expected deprecation flow.
Kindly let me know if anything else needs improvement — happy to update further.
Thanks for reviewing 🙏
Comment #10
nicxvan commentedWe will need a test for the deprecation too, you can add a theme settings file to the test procedural hook theme
Comment #11
nicxvan commentedI pushed up a fix for the deprecation message format.
I only see one other sprintf in deprecations, but I left it here for now.
We do still need to add a test for the deprecation path since it's unique, but we should do this after the actual .theme deprecation.
#3581218: Deprecate .theme file extension
Comment #12
nicxvan commentedWhy did you change the hook implementation so much?
Comment #13
nicxvan commentedI'm very confused, both the MR and the patch have incorrect versions of the conversion. Can you both please provide information on how you did the conversion and why over 100 lines were deleted?
Comment #14
debdeep.mukhopadhyay commentedHi @nicxvan,
can you please little eleborate which part conversion seems incorrect,it's help me better for understand and for the right correction.
Comment #15
nicxvan commentedComment #16
nicxvan commentedI rebased and updated the deprecation message, we still need tests.
Comment #17
nicxvan commentedComment #20
nicxvan commentedComment #21
nicxvan commentedI closed the other MR cause I think something was broken there, I had already addressed the deprecation issue that @oily pointed out, but it was the right thing. The comment about the settings language should be a follow up.
This is green now and ready for review!
Comment #22
smustgrave commentedDiscussed this with @nicxvan in slack.
Had questions about if D12 was too soon but he made a good point that it's not a lot of code and not complex enough to push out.
2nd question was the use of " move to the .theme file" since those are going away and he reminded me that .theme won't go away till D13.
Rest looks good.
Comment #23
mstrelan commentedIt seems strange that we would recommend moving code to a .theme file for D12 when .theme file extensions have been deprecated.
Comment #24
nicxvan commentedThe primary recommendation is to convert the hooks.
The recommendation to move to the .theme file is only if the theme has to support lower than 11.3 simultaneously with 12.
Comment #25
nicxvan commentedI updated the CR for clarity.
Comment #26
mstrelan commentedThanks for updating the CR. For me, the CR was already clear, it's the deprecation message that bothered me. I think many would go for the quick fix of moving it, only to have to move it again later. That may be fine though, and is supported through D12.
Comment #27
nicxvan commentedYeah it's just one hook and it's not super common to use this feature.
I think it's fine if some percentage of people copies and pastes the function then later has to convert it.
Comment #28
catchYes I think this is reasonable to deprecate for removal in 12.0.0, it's very rarely used, and helps us simplify the bc layer that we do want to support through to Drupal 13.
Committed/pushed to main, thanks!
Needs a backport MR for 11.x
Comment #31
nicxvan commentedBackport should be ready!
Conflict was just in the themesettings test.
The failure looks like a random functionalJS test:
Drupal\FunctionalJavascriptTests\BrowserWithJavascriptComment #33
catchCommitted/pushed to 11.x, thanks!
Comment #35
nicxvan commented