PHP type error when saving content type

Created on 14 March 2019, over 5 years ago
Updated 21 August 2023, about 1 year ago

This may manifest with a particular set of circumstances, like specific other modules being enabled, but my site is failing with the following PHP error when I save a content type:

TypeError: Argument 2 passed to node_type_class_form_node_type_form_builder() must be an instance of NodeTypeInterface, instance of Drupal\node\Entity\NodeType given in node_type_class_form_node_type_form_builder() (line 40 of modules\contrib\node_type_class\node_type_class.module).

Debugging the code I find the main problem is the NodeTypeInterface in the referenced method is not fully qualified, so when it runs the correct interface is apparently not loaded (otherwise it would work since NodeType implements NodeTypeInterface).

The attached patch fixes the specific problem and also slightly changes the use of FormStateInterface to comply with the Drupal coding standards documentation. (This is my first ever contribution, so let me know if the patch PHPStorm created is incorrect format or something.)

🐛 Bug report
Status

RTBC

Component

Code

Created by

🇺🇸United States dan_billingsley

Live updates comments and jobs are added and updated live.
  • Quick fix

    Very small and simple change. Preferred over Quickfix.

  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

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.

Production build 0.71.5 2024