Problem/Motivation
The upgrade hook 10006 from 2.0.0-alpha2 to 2.0.0-alpha3 probably fails to convert fieldset string to group with machine name.
Steps to reproduce
Tested on Drupal 10.2.2 (before composer update run below)
- Take a backup of your database!
- using site_settings 2.0.0-alpha2
- having 2 Site Setting types setup and site setting entities added
composer update, which upgrades site_settings (2.0.0-alpha2 => 2.0.0-alpha3)drush cr- Run update hooks
drush updb
Log:--------------- --------------------- --------------- ------------------------------------------------------------------------ Module Update ID Type Description --------------- --------------------- --------------- ------------------------------------------------------------------------ site_settings 10006 hook_update_n 10006 - Convert fieldset string to group with machine name. site_settings 10007 hook_update_n 10007 - Re-install view. site_settings 1_make_revisionable post-update Makes site_settings entities revisionable. site_settings 2_make_revisionable post-update Add default revision values. site_settings check_loader post-update Re-run set the default site settings loader to flattened if upgrading. --------------- --------------------- --------------- ------------------------------------------------------------------------ Do you wish to run the specified pending updates? (yes/no) [yes]: > yes > [notice] Update started: site_settings_update_10006 > [notice] Update completed: site_settings_update_10006 > [notice] Update started: site_settings_update_10007 > [notice] Update completed: site_settings_update_10007 > [notice] Update started: site_settings_post_update_1_make_revisionable > [warning] Undefined array key "fieldset" site_settings.post_update.php:64 > [notice] Site setting entities have been converted to be revisionable. > [notice] Update completed: site_settings_post_update_1_make_revisionable > [notice] Update started: site_settings_post_update_2_make_revisionable > [notice] Update completed: site_settings_post_update_2_make_revisionable > [notice] Update started: site_settings_post_update_check_loader > [notice] Update completed: site_settings_post_update_check_loader - Go back to the site to observe the WSOD, error:
The website encountered an unexpected error. Try again later. TypeError: Drupal\site_settings\Plugin\SiteSettingsLoader\FlattenedSiteSettingsLoader::groupKey(): Argument #1 ($group) must be of type string, null given, called in /var/www/html/web/modules/contrib/site_settings/src/Plugin/SiteSettingsLoader/FlattenedSiteSettingsLoader.php on line 226 in Drupal\site_settings\Plugin\SiteSettingsLoader\FlattenedSiteSettingsLoader->groupKey() (line 394 of modules/contrib/site_settings/src/Plugin/SiteSettingsLoader/FlattenedSiteSettingsLoader.php). Drupal\site_settings\Plugin\SiteSettingsLoader\FlattenedSiteSettingsLoader->buildSettings('en') (Line: 167) Drupal\site_settings\Plugin\SiteSettingsLoader\FlattenedSiteSettingsLoader->rebuildCache('en') (Line: 158) Drupal\site_settings\Plugin\SiteSettingsLoader\FlattenedSiteSettingsLoader->loadAll() (Line: 27) site_settings_token_info() call_user_func_array(Object, Array) (Line: 409) Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'site_settings') (Line: 388) Drupal\Core\Extension\ModuleHandler->invokeAllWith('token_info', Object) (Line: 408) Drupal\Core\Extension\ModuleHandler->invokeAll('token_info') (Line: 40) Drupal\token\Token->getInfo() (Line: 99) Drupal\token\Token->getTokenInfo('node', 'path') (Line: 57) Drupal\token\TokenModuleProvider->resolveCacheMiss('node::path') (Line: 149) Drupal\Core\Cache\CacheCollector->get('node::path') (Line: 49) Drupal\token\TokenModuleProvider->getTokenModule('node', 'path') (Line: 1754) _field_tokens('entity', Array, Array, Array, Object) (Line: 503) token_tokens('entity', Array, Array, Array, Object) call_user_func_array(Object, Array) (Line: 409) Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'token') (Line: 388) Drupal\Core\Extension\ModuleHandler->invokeAllWith('tokens', Object) (Line: 408) Drupal\Core\Extension\ModuleHandler->invokeAll('tokens', Array) (Line: 364) Drupal\Core\Utility\Token->generate('entity', Array, Array, Array, Object) (Line: 1097) token_tokens('node', Array, Array, Array, Object) call_user_func_array(Object, Array) (Line: 409) Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'token') (Line: 388) Drupal\Core\Extension\ModuleHandler->invokeAllWith('tokens', Object) (Line: 408) Drupal\Core\Extension\ModuleHandler->invokeAll('tokens', Array) (Line: 364) Drupal\Core\Utility\Token->generate('node', Array, Array, Array, Object) (Line: 241) Drupal\Core\Utility\Token->doReplace(1, '[node:path]', Array, Array, Object) (Line: 191) Drupal\Core\Utility\Token->replace('[node:path]', Array, Array, NULL) (Line: 66) Drupal\metatag\MetatagToken->replace('[node:path]', Array, Array) (Line: 789) Drupal\metatag\MetatagManager->processTagValue(Object, Array, Array, , 'en') (Line: 628) Drupal\metatag\MetatagManager->generateRawElements(Array, Object) (Line: 564) Drupal\metatag\MetatagManager->generateElements(Array, Object) (Line: 504) metatag_get_tags_from_route() (Line: 258) _metatag_remove_duplicate_entity_tags(Array) (Line: 218) metatag_entity_view_alter(Array, Object, Object) (Line: 545) Drupal\Core\Extension\ModuleHandler->alter('node_view', Array, Object, Object) (Line: 304) Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 238) Drupal\Core\Entity\EntityViewBuilder->build(Array) call_user_func_array(Array, Array) (Line: 111) Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858) Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array, ) (Line: 238) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231) Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) call_user_func(Array, Object, 'kernel.view', Object) (Line: 111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44) Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28) Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Only way to bring the site back is to rollback the composer update and re-import an archive db.
Proposed resolution
I suspect that the upgrade hook is failing doing the conversion of fieldset string to group with machine name.
Remaining tasks
Fix the upgrade hook.
Issue fork site_settings-3446920
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
scott_euser commentedI couldn't manage to reproduce this for now, will have to see if anyone can manage to give further steps.
Comment #3
roromedia commentedThis happened to me as well on a couple of sites I had to upgrade. The problem is that the "Choose existing "Group" label"-dropdown is empty in /admin/structure/site_setting_entity_type/YOUR_KEY/edit
To quickly get around you can comment the
in Line 226 of web/modules/contrib/site_settings/src/Plugin/SiteSettingsLoader/FlattenedSiteSettingsLoader.php out and then go to your groups and make sure that you select a value in the above mentioned dropdown. Then remove your comment again and the site works.
Comment #4
scott_euser commentedMaybe as a temp solution we can add an is_string() wrapper to that to allow people to fix a failed upgrade without fatal error? Ie fix the symptom until the root problem happening to some upgrades can be solved...
Comment #5
roromedia commentedYes, that would be very helpful. I tried some edge cases like removing the group without removing the settings etc. on a dev environment but all of this is already handled by the module so it seems this are legacy issues from 1.x to 2.x maybe.
Comment #7
scott_euser commentedLetting tests run
Comment #9
scott_euser commentedProbably not perfect but at least avoids fatal error and let's the edit fix the problem.