Provide upgrade path for "node_type" condition

Created on 17 July 2023, over 1 year ago
Updated 8 December 2023, 12 months ago

Problem/Motivation

After upgrading to Drupal 10, the following exception is thrown if the :

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist.

And is related to the https://www.drupal.org/node/2983299 β†’ change record.

The module requires an upgrade path to use the new plugin ID.

Steps to reproduce

Have an existing context entity with the following condition

conditions:
  node_type:
    id: node_type
    negate: false
    uuid: 743e0cb0-b14d-4504-9de1-20bb3c25c2ee
    context_mapping:
      node: '@node.node_route_context:node'
    bundles:
      basic_page: basic_page

and attempt an upgrade to D10.

Proposed resolution

Provide an upgrade path from node_type to entity_bundle:node

The update hook should only be ran on Drupal 9.3 and up.

Remaining tasks

User interface changes

N/A

API changes

N/A

Data model changes

N/A.

πŸ› Bug report
Status

RTBC

Version

5.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @codebymikey
  • @codebymikey opened merge request.
  • Status changed to Needs review over 1 year ago
  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

    RTBC +1
    Patch working for me, thank you!

  • πŸ‡©πŸ‡ͺGermany e5sego

    Patch from #3 worked like a charm and erstored my site from beeing broken by the D10 upgrade.

  • πŸ‡¬πŸ‡§United Kingdom Rob230

    I'm getting that error in the update hook that comes with 5.x (the D10 version of the module):

    > [notice] Update started: context_update_8004
    > [error] The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: condition_group, config_pages_values_access, user_status, ... entity_bundle:paragraph
    > [error] Update failed: context_update_8004
    [error] Update aborted by: context_update_8004
    [error] Finished performing updates.

    Therefore, the post_update hook in patch #3 cannot ever run.

    I've used the patch on D9.5 and used that as an intermediate deployment step before upgrading to D10 and context 5.x.

    So should this be issue be for context 8.x-4.x so that it can run before D10? The change record is for Drupal 9.3.

  • πŸ‡¬πŸ‡§United Kingdom Rob230

    Oh that upgrade hook might have also been blocked by a block config which doesn't get updated by the patch. So I've changed that block config first and now it runs.

Production build 0.71.5 2024