- Issue created by @dieterholvoet
- Merge request !8758Fix infinite loop caused by 'user.permissions' cache context. β (Open) created by dieterholvoet
- Status changed to Needs review
6 months ago 9:36am 14 July 2024 Is xdebug enabled? I remember there were issues with that, although this of course may be unrelated.
- π§πͺBelgium dieterholvoet Brussels
Oh and might be worth mentioning, the
user.permissions
cache context is attached to the role entity, which at some point is added as cacheable dependency. - Status changed to Needs work
6 months ago 1:56pm 15 July 2024 - πΊπΈUnited States smustgrave
MR should be updated for 11.x
Nothing major stuck out but definitely seems like something that will need test coverage
- π©πͺGermany geek-merlin Freiburg, Germany
@Dieter
I debugged a similar thing lately, it looks like the new permission negitiation code is not robust against some config override cacheability.
Can yougrep "implements ConfigFactoryOverrideInterface" modules
? - π§πͺBelgium dieterholvoet Brussels
That's it! The following class in my custom code seems to be the culprit. I don't think I'm doing anything wrong there though?
<?php namespace Drupal\my_module\Config; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Session\AccountProxyInterface; class MenuBreadcrumbConfigOverrides implements ConfigFactoryOverrideInterface { public function __construct( protected AccountProxyInterface $currentUser, ) { } public function loadOverrides($names): array { $overrides = []; if (!in_array('menu_breadcrumb.settings', $names, true)) { return $overrides; } if ($this->currentUser->hasPermission('access toolbar')) { if ($this->currentUser->hasPermission('access editor toolbar')) { $overrides['menu_breadcrumb.settings']['menu_breadcrumb_menus']['editor']['enabled'] = 1; } else { $overrides['menu_breadcrumb.settings']['menu_breadcrumb_menus']['admin']['enabled'] = 1; } } return $overrides; } public function getCacheSuffix(): string { return 'MenuBreadcrumbConfigOverrides'; } public function getCacheableMetadata($name): CacheableMetadata { return (new CacheableMetadata()) ->addCacheContexts(['user.permissions']); } public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) { return null; } }
- π©πͺGermany geek-merlin Freiburg, Germany
Yo! I made the same omission in translation_bliss module, now fixed:
You need a $name check in getCacheableMetadata.That said, imho it's still a core bug if it WSODs on too much config cachability.
- π§πͺBelgium dieterholvoet Brussels
You're right, that fixes it for me. Thanks!