Hi there,
I get an error when I try to create a context which should switch active theme as reaction whilst also using the current theme condition.

How to reproduce the error

  • Create a new context "context A"
  • Specify a theme condition (where theme is Bartik etc.)
  • Choose a reaction such a adding body class.
  • Save and continue
  • ---
  • Create a new context "context B"
  • Specify a path by using the request path condition
  • Choose a theme by using the Theme reaction
  • Save and continue (crashes here)

What happens while saving...

A new context will be created but with the following issues:

  • The context ThemeSwitcherNegotiator class tries to get current contexts to set theme
  • the current condition context for theme condition is called recursively as result.

Final result

The Theme Manager tries to define the active theme by calling the ::applies() method for every theme negotiator. When this method is called for Context Theme Switcher Negotiator, it tries to discover itself the active theme (this means the Theme Manager will start again the theme discovery logic ending in calling again the applies method of the Context Theme Switcher Negotiator), by causing an infinite loop on every page of your website.

The website encountered an unexpected error. Please try again later.
Error: Maximum function nesting level of '256' reached, aborting! in Drupal\Core\Condition\ConditionPluginBase->defaultConfiguration() (line 107 of core/lib/Drupal/Core/Condition/ConditionPluginBase.php).
Drupal\Core\Condition\ConditionPluginBase->defaultConfiguration() (Line: 73)
Drupal\system\Plugin\Condition\CurrentThemeCondition->defaultConfiguration() (Line: 100)
Drupal\Core\Condition\ConditionPluginBase->setConfiguration(Array) (Line: 37)
Drupal\Core\Condition\ConditionPluginBase->__construct(Array, 'current_theme', Array) (Line: 51)
Drupal\system\Plugin\Condition\CurrentThemeCondition->__construct(Array, 'current_theme', Array, Object, Object) (Line: 65)
Drupal\system\Plugin\Condition\CurrentThemeCondition::create(Object, Array, 'current_theme', Array) (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('current_theme', Array) (Line: 58)
Drupal\Core\Condition\ConditionManager->createInstance('current_theme', Array) (Line: 81)
Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin('current_theme') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('current_theme') (Line: 26)
Drupal\Core\Condition\ConditionPluginCollection->get('current_theme') (Line: 148)
Drupal\Component\Plugin\LazyPluginCollection->getIterator() (Line: 302)
Drupal\context\ContextManager->applyContexts(Object) (Line: 276)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 107)
Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate() (Line: 74)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Drupal\context\ContextManager->resolveConditions(Object, 'and') (Line: 289)
Drupal\context\ContextManager->evaluateContextConditions(Object) (Line: 201)
Drupal\context\ContextManager->evaluateContexts() (Line: 189)
Drupal\context\ContextManager->getActiveContexts() (Line: 220)
Drupal\context\ContextManager->getActiveReactions('theme') (Line: 56)
Drupal\context\Theme\ThemeSwitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 403)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 74)
Drupal\Core\Render\ElementInfoManager->getInfo('form') (Line: 810)
Drupal\Core\Form\FormBuilder->prepareForm('context_edit_form', Array, Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('context_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 665)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed solution

Let's add an "evaluated" property within the ThemeSwitcherNegotiator class to be used as a flag to avoid this kind of infinite recursion.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aronne created an issue. See original summary.

aronne’s picture

Here it is the patch which is working fine for me.
Hope it helps.

Regards

brandonratz’s picture

#2 Patch addressed a similar issue for me.

bzoks’s picture

Status: Needs review » Postponed (maintainer needs more info)

I was not able to reproduce the issue in Drupal 8.7 using module version 8.x-4.x-dev and also not on module version 8.x-4.0-beta2.
Are you sure you used one of those versions?

Patch #2 does solve some other issue, which it seems is not reported separately yet
Notice: Undefined index: theme in Drupal\context\Theme\ThemeSwitcherNegotiator->applies() (line 58 of modules/contrib/context/src/Theme/ThemeSwitcherNegotiator.php)
Part of a patch that fixes this is:

       // Be sure the theme key really exists.
       if (isset($configuration['theme'])) {

If the original issue won't be reproducible, this other issue should be reported and solved separately.

Best regards,
Bostjan

silverham’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

I can confirm there is an issue when the condition "current theme (System)" is used at the same time as a "theme" reaction.

See line in back trace:

Drupal\system\Plugin\Condition\CurrentThemeCondition->evaluate()

This causes a recursive loop:

  • The "CurrentThemeCondition" wants to find the active theme so it triggers $this->themeManager->getActiveTheme()
  • which then triggers ThemeSwitcherNegotiator->applies()
  • which then triggers ThemeSwitcherNegotiator->getActiveReactions()
  • which then tries to get the current contexts and then their conditions which loops again etc.

-

The patch prevents a second call to find the active theme if it has already tried.
I have tested it and confirmed it works good.

silverham’s picture

Issue summary: View changes
paulocs’s picture

Thanks @silverham! I could reproduce it too.
I'm not sure if it is in the scope of the issue, but if one context has condition Current Theme = Bartik and reaction Body class = "test-class" and the other context has condition Request Path = and reaction Theme = Claro, the class "test-class" is added in the body tag on the front page.

  • paulocs committed 0701edb on 8.x-4.x authored by aronne
    Issue #3024989 by aronne, silverham, bzoks, paulocs: "Maximum function...
paulocs’s picture

Status: Reviewed & tested by the community » Fixed

I committed it in dev-branch. About my comment #7, in my opinion it is working as it suppose to be.

Thanks @all :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

silverham’s picture

Thanks @paulocs !! :-)