Database update needed to replace the node_type condition with entity_bundle:node

Created on 7 March 2025, 29 days ago

Problem/Motivation

This module apparently does not update its config during upgrades from the old Drupal 9 condition plugins to the new Drupal 10 ones. Stored config, therefore, still has references to "node_type" resulting in fatal errors like this:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: user_status, request_path_exclusion, http_status_code, context_all, request_domain, context, view_inclusion, gtag_domain, gtag_language, language, response_status, current_theme, request_path, user_role, entity_bundle:bibcite_reference, entity_bundle:block_content, entity_bundle:media, entity_bundle:node, entity_bundle:paragraph, entity_bundle:redirect, entity_bundle:shortcut, entity_bundle:taxonomy_term, entity_bundle:menu_link_content in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/html/code/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Steps to reproduce

Upgrade a site using node_type conditions from D9 to D10, then visit any page and witness a fatal error.

Proposed resolution

We need to add an update hook to replace these. Pathauto has something similar which can be seen here:
https://git.drupalcode.org/project/pathauto/-/merge_requests/5/diffs?com...

Remaining tasks

I'll see if I can take a whack at this based on the other example.

User interface changes

API changes

Data model changes

None, purely upgrade cleanup.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States seanr

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

Comments & Activities

  • Issue created by @seanr
  • πŸ‡ΊπŸ‡ΈUnited States seanr

    LOL, I really didn't get very far with this - going to need some help from folks who understand this stuff far better than I and it's also not clear it actually belongs in this model rather than context itself:

    /**
     * Update node type conditions from node_type to entity_bundle.
     */
    function context_active_trail_update_8001(): void {
      foreach (Drupal::service('context.manager')->getContexts() as $context) {
        foreach ($context->getConditions() as $condition) {
          if ($condition['id'] === 'node_type') {
            $condition['id'] = 'entity_bundle:node';
          }
        }
      }
      drupal_flush_all_caches();
    }
    
  • πŸ‡ΊπŸ‡ΈUnited States seanr

    Indeed, looks like the solution is over here: πŸ› Provide upgrade path for "node_type" condition RTBC .

Production build 0.71.5 2024