Replace use of node_type condition

Created on 1 November 2022, about 2 years ago
Updated 4 September 2024, 3 months ago

Problem/Motivation

CTools 8.x-3.11 deprecated the 'node_type' condition plugin in favor of 'entity_bundle:node'.

Note that exported view_mode_page configs can be manually changed to use 'entity_bundle:node' as suggested in https://www.drupal.org/project/ctools/releases/8.x-3.11-rc1 , but as soon as an admin tries to update them through view_mode_page's admin UI, that gets reverted.

Steps to reproduce

Create/edit a view mode page (even one that had its config export manually changed), and find that it ends up using the 'node_type' condition plugin. Deprecation messages will be logged.

Proposed resolution

Whilst view_mode_page can work with 'entity_bundle:node', and in fact does by default for entities other than nodes, it explicitly switches to use 'node_type' for nodes. Just like was done in pathauto 8.x-1.10 , view_mode_page should provide an update hook to switch existing config over to using 'entity_bundle:node', and use that instead of node_type throughout its code. The same kind of instructions that were in the nodes for that pathauto release could be copied for view_mode_page too.

Remaining tasks

* Review patch
* Produce release notes with guidance based on https://www.drupal.org/project/pathauto/releases/8.x-1.10

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom james.williams

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States loopy1492

    > Unexpected error during import with operation update for view_mode_page.pattern.[WHATEVER]: The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Co
    ndition\ConditionManager are: language, current_theme, request_path, user_role, webform, entity_bundle:block_content, entity_bundle:comment, entity_bundle:crop, entity_bundle:feed
    s_feed, entity_bundle:media, entity_bundle:node, entity_bundle:paragraph, entity_bundle:redirect, entity_bundle:shortcut, entity_bundle:taxonomy_term, entity_bundle:webform_submis
    sion, entity_bundle:menu_link_content

    As of now, the only option is to manually update the config yourself from `node_type` to `entity_bundle:node`

  • 🇺🇸United States loopy1492

    it looks like this is being fixed as a part of https://www.drupal.org/project/view_mode_page/issues/3300706 🐛 Context exception when trying to create url (Drupal 10 is broken!) RTBC

  • 🇺🇸United States jessehs Taos, New Mexico

    Looks like most of the issue was fixed in the 4.0.x dev branch. However, sites with existing config will still break. This patch adds an update hook to fix the issue with existing config. (After this process you will still need to export config and commit it to version control however.)

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States jessehs Taos, New Mexico
  • 🇪🇸Spain rcodina Barcelona

    Patch on #4 works like a charm.

Production build 0.71.5 2024