PluginNotFoundException: The "node_type" plugin does not exist.

Created on 16 May 2024, about 1 month ago
Updated 19 May 2024, 29 days ago

After upgrading Drupal 9 to 10

Script items filtered by node type return an error on the admin script manager item page UI and all over the front website pages.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: gtag_domain, gtag_language, current_theme, response_status, request_path, ua_is_campaign_page, user_role, webform, entity_bundle:block_content, entity_bundle:crop, entity_bundle:media, entity_bundle:node, entity_bundle:redirect, entity_bundle:scheduled_update, entity_bundle:taxonomy_term, entity_bundle:webform_submission, entity_bundle:menu_link_content, entity_bundle:paragraph in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 59)
Drupal\Core\Condition\ConditionManager->createInstance() (Line: 81)
Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin() (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get() (Line: 26)
Drupal\Core\Condition\ConditionPluginCollection->get() (Line: 149)
Drupal\Component\Plugin\LazyPluginCollection->getIterator() (Line: 99)
Drupal\script_manager\Entity\ScriptAccessControlHandler->getPreparedConditions() (Line: 63)
Drupal\script_manager\Entity\ScriptAccessControlHandler->checkAccess() (Line: 109)
Drupal\Core\Entity\EntityAccessControlHandler->access() (Line: 329)
Drupal\Core\Entity\EntityBase->access() (Line: 71)
Drupal\script_manager\ScriptPlacementManager->getRenderedScriptsForPosition() (Line: 26)
script_manager_page_top() (Line: 352)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 353)
Drupal\Core\Render\MainContent\HtmlRenderer->buildPageTopAndBottom() (Line: 146)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia gigimaor Gold Coast/Brisbane

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @gigimaor
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    You need to update your config to use bundle:node

  • πŸ‡¦πŸ‡ΊAustralia gigimaor Gold Coast/Brisbane

    Thank you Lee
    In my case, the configurations are being ignored, and our Drupal is used on multiple websites. Some of them might return errors after the upgrade.
    I suggest manually deselecting the node bundle, before the upgrade, and selecting a different visibility solution instead. Missing doing that could cause a cross-website error.

    I used a post-update function to migrate all node types to bundle:node, as Lee suggested above, to run it during the upgrade deployment process or after.

    /**
     * Fix script_manager module node_type issue.
     *
     */
    function ua_post_update_script_manager_node_type(){
      // Fix script manager settings.
      $config_factory = \Drupal::service('config.factory');
      $script_manager_settings = $config_factory->listAll('script_manager.settings');
      $config = $config_factory->getEditable($script_manager_settings[0]);
      $enabled_visibility_plugins = $config->get('enabled_visibility_plugins');
      if (is_array($enabled_visibility_plugins)) {
        $enabled_visibility_plugins = array_replace($enabled_visibility_plugins,
          array_fill_keys(
            array_keys($enabled_visibility_plugins, 'node_type'),
            'entity_bundle:node'
          )
        );
        $config->set('enabled_visibility_plugins', $enabled_visibility_plugins);
        $config->save();
      }
      // Fix script manager items.
      $config_factory = \Drupal::service('config.factory');
      $script_manager_configurations  = $config_factory->listAll('script_manager.script');
      foreach ($script_manager_configurations as $config_name) {
        // Load the block configuration.
        $config = $config_factory->getEditable($config_name);
    
        // Check for a value and update it if needed.
        if (is_array($config->get('visibility.node_type'))) {
          if ($config->get('visibility.node_type')['id'] === 'node_type') {
            $config->set('visibility.node_type.id', 'entity_bundle:node');
            $config->save();
          }
        }
      }
    }
    
    
Production build 0.69.0 2024