Problem/Motivation
After changing the admin theme to 'Olivero' or "Standard', I'm getting this error.
Steps to reproduce
- Do a clean install of Drupal core 11.3.5
- After installation, you're logged in as an admin with the admintheme Claro. The Olivero theme is selected for the anonymous user. Check this in .../admin/appearance.
- Access the page .../admin/appearance/settings and you will see the general settings
- Go back to the page .../admin/appearance and go to the bottom of this page.
- Change the admin theme to Olivera or Standard. (Because Olivera was the standard theme, the result is the same)
- Access again the .../admin/appearance/settings page
I'm seeing this PHP error:
InvalidArgumentException: Class "olivero_form_system_theme_settings_alter" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 32 of core/lib/Drupal/Core/DependencyInjection/ClassResolver.php).
Drupal\Core\Utility\CallableResolver->getCallableFromDefinition() (Line: 592)
Drupal\Core\Theme\ThemeManager->getImplementationsForTheme() (Line: 556)
Drupal\Core\Theme\ThemeManager->alterForTheme() (Line: 620)
Drupal\Core\Theme\ThemeManager->alter() (Line: 893)
Drupal\Core\Form\FormBuilder->prepareForm() (Line: 304)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 634)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->start() (Line: 635)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 745)
Drupal\Core\DrupalKernel->handle() (Line: 19)
This error does not appair on a Drupal 10 system.
My PHP-version is 8.3
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3581226
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
quietone commentedHi, Issues for Drupal core should be targeted to the 'main' branch, our primary development branch. Changes are made on the main branch first, and are then back ported as needed according to the Core change policies. The version the problem was discovered on should be stated in the issue summary Problem/Motivation section. Thanks.
I followed the steps in the issue summary and was not able to reproduce the problem. I am not sure what "Change the admin theme to Olivera or Standard" means because there is no 'Standard' theme in core. Where does Standard come from?
Comment #3
ericvlHi,
Thank you for your quick response.
Sorry, I didn't know about the policy to make new issues against the main branch. Glad it is on the right track now.
About the selection of the admin theme on this page. I had to translate it from Dutch to English and that probably didn't work out so good.
There is a listbox on the bottom of the page with 3 possibilities; "Standard" or " Default if you wish, Olivero and Claro. This is the one that you should change to Standard or Olivero. Save it and go to the page .../admin/appearance/settings. Then you will see the php error.
Greetings
Comment #4
ericvlComment #5
cilefen commentedI am unable to reproduce this bug as written. Perhaps there are additional steps to reproduce?
Comment #6
ericvlStrange
Run "standard" installation in Dutch and then follow the setup above.
Success
Comment #7
cilefen commentedAh, I missed the detail about going to the Appearance > Settings page! This is reproducible in any language.
Comment #8
nicxvan commentedInteresting, the ThemeSettingsForm has this:
before:
$this->themeManager->alterForTheme($editing_active_theme, 'form_system_theme_settings', $form, $form_state);Comment #9
cilefen commentedThis bug released in 11.3.0-rc2.
Comment #10
shreyal999 commentedThe same issue is still happening in 11.3.5
Comment #11
ericvl@shreyal999
Any progress on this issue?
Comment #12
cilefen commented@shreyal999, this was reported for 11.3.5, and it hasn’t been fixed. What I said was that this bug released in 11.3.0-rc2, meaning that is when the bug appeared in a tag. Apologies if I wasn’t clear.
This obviously needs test coverage
Comment #13
cilefen commentedThe likely cause is #3560833: Create better way to manage theme setting alters.
Comment #14
nicxvan commentedYes we probably just need to move that include logic somewhere higher.
Comment #15
nicxvan commentedI pushed up a fix, we can probably narrow down to the current theme and I have not added tests yet.
Comment #17
ericvl@nixvan
I've patched locally my 11.3.5 version with the contents of your merge request and I can say that the patch works. Ofcourse I don't know if this is the way to go because I don't have a clear view on the code. Thanks for your input.
Comment #18
ericvl@nixvan
Another constatation after applying your path.
I do not get the PHP-error anymore but the form is different from the one created under core version 10.
Under version 11.5.3 I'm getting some extra settings from the Olivero theme although I'm selecting the general settings with .../admin/appearance/settings.
Under version 10 I'm only getting the general settings Page-element display, Logo and Favicon, wich is correct.
Greetings
Comment #19
jwilson3Until this gets fixed in core, one way to guard against this without the patch from this issue it is to move your theme settings form alter into *.theme so that it is always registered. This may or may not be a good idea.
My diff looks something like this:
Comment #20
nicxvan commentedThat is a valid way to fix this.
The actual recommendation is to convert the hook to oop which is supported since 11.3.
Separate theme.settings does were deprecated in 11.4 and removed in 12.
That's interesting, I probably included too many themes in the loop.
Converting the hook should fix this and then you don't need the patch.
Comment #21
jwilson3Thanks for that. I was seeing this as a Drupal 12 compatibility addition, but might make sense to go ahead and add that. The D12-compatibility issue for my theme doesn't (yet) have an automated rector fix for converting theme-settings.php to oop.
The extra settings might be appearing due to #943212: hook_form_system_theme_settings_alter() vs. THEME_form_system_theme_settings_alter() name-clash, which I guard for using the $form_id parameter, if $form_id is empty, then its the global settings form, and I therefore skip my custom theme additions. Sadly that issue was closed. I might be totally wrong about this.