Skip to main content
Old-fashioned half-used colorful red and blue fireworks box, labeled 'Thunder Bomb' with the warning Caution-Explosive in large capitalized letters.

Drupal 9 Component Plugin ContextException "not a valid context"

after CTools, Symfony update

Upgrading to CTools 3.10.0 and/or various Symfony upgrades can break the simple task of adding content on your Drupal site.

Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. in Drupal\Core\Executable\ExecutablePluginBase->getContextDefinition() (line 184 …

Update:  Seems confirmed this is CTools, see critical bug issue.

And this fixed it:

git revert 0fbbbaf
[main 7be1cd2] Revert fatal error standard code update "Update composer lock"
 1 file changed, 163 insertions(+), 220 deletions(-)
saharareporters [main]$ dco install # that is, composer install - dco is my alias for ddev composer
Gathering patches for root package.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Package operations: 0 installs, 27 updates, 1 removal
  - Removing drupal/entityqueue (1.2.0)
Deleting web/modules/contrib/entityqueue - deleted
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Downgrading drupal/core-composer-scaffold (9.4.4 => 9.4.3): Extracting archive
  - Downgrading symfony/yaml (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading symfony/translation (v4.4.44 => v4.4.41): Extracting archive
  - Downgrading symfony/event-dispatcher (v4.4.44 => v4.4.42): Extracting archive
  - Downgrading symfony/dependency-injection (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading symfony/console (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading symfony/filesystem (v5.4.11 => v5.4.9): Extracting archive
  - Downgrading symfony/config (v4.4.44 => v4.4.42): Extracting archive
  - Downgrading symfony/css-selector (v5.4.11 => v5.4.3): Extracting archive
  - Downgrading symfony/dom-crawler (v4.4.44 => v4.4.42): Extracting archive
  - Downgrading symfony/browser-kit (v4.4.44 => v4.4.37): Extracting archive
  - Downgrading symfony/finder (v6.1.3 => v6.1.0): Extracting archive
  - Downgrading symfony/validator (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading symfony/serializer (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading symfony/routing (v4.4.44 => v4.4.41): Extracting archive
  - Downgrading symfony/mime (v5.4.11 => v5.4.10): Extracting archive
  - Downgrading symfony/http-foundation (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading symfony/process (v4.4.44 => v4.4.41): Extracting archive
  - Downgrading symfony/var-dumper (v5.4.11 => v5.4.9): Extracting archive
  - Downgrading symfony/debug (v4.4.44 => v4.4.41): Extracting archive
  - Downgrading symfony/error-handler (v4.4.44 => v4.4.41): Extracting archive
  - Downgrading symfony/http-kernel (v4.4.44 => v4.4.43): Extracting archive
  - Downgrading drupal/migmag (1.8.1 => 1.8.0): Extracting archive
  - Downgrading symfony/string (v6.1.3 => v6.1.2): Extracting archive
  - Downgrading drupal/noreferrer (1.14.0 => 1.13.0): Extracting archive
  - Downgrading drupal/ctools (3.10.0 => 3.9.0): Extracting archive
  - Downgrading symfony/mailer (v5.4.11 => v5.4.10): Extracting archive

And a drush cache-reload, of course.

Full error, for search engines:

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. in Drupal\Core\Executable\ExecutablePluginBase->getContextDefinition() (line 184 of core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php).

Drupal\Core\Executable\ExecutablePluginBase->getContext(NULL) (Line: 116)
Drupal\Core\Executable\ExecutablePluginBase->getContextValue(NULL) (Line: 91)
Drupal\Core\Entity\Plugin\Condition\EntityBundle->evaluate() (Line: 77)
Drupal\Core\Condition\ConditionManager->execute(Object) (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 376)
Drupal\pathauto\Entity\PathautoPattern->applies(Object) (Line: 320)
Drupal\pathauto\PathautoGenerator->getPatternByEntity(Object) (Line: 41)
Drupal\pathauto\PathautoWidget->formElement(Object, 0, Array, Array, Object) (Line: 353)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 220)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object) (Line: 111)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 181)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 127)
Drupal\node\NodeForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 531)
Drupal\Core\Form\FormBuilder->retrieveForm('node_article_form', Object) (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 97)
Drupal\autosave_form\Form\AutosaveFormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
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: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->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: 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: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

2022 September 08
ben "mlncn" melançon

Permalink

If you are still getting…

If you are still getting this error now, it is almost certainly because your version of CTools after a composer update is 4.0.1, which is knowingly and ridiculously as broken as 3.10.0 was.

You can fix it by adding this to your composer.json file:

        "drupal/ctools": "^3.11",

Add new comment

The content of this field is kept private and will not be shown publicly.

Markdown

The comment language code.
CAPTCHA Please help us focus on people and not spambots by answering this question.