When using hook_node_type_update I discovered the orig_type value is always being set to the same value as the type value. Looking at the node_type_set_defaults function I'm realizing on line 830:

$new_type->orig_type = isset($info['type']) ? $info['type'] : '';

we are assuming $info['orig_type'] never has a previous value, which in the case of updates it does. It's only in the case of an insert it does not. It seems like changing the logic to check for the orig_type value first, and otherwise set it to the $info['type'] would make more sense. I can't imagine a scenario where we would ever need to set it equal to '', and there isn't a value for $info['type'].

I propose changing it to this:

  $new_type->orig_type = !empty($info['orig_type']) ? $info['orig_type'] : $info['type'];

I'll include a patch.

Comments

asherry’s picture

Status: Active » Needs review
StatusFileSize
new528 bytes
asherry’s picture

Assigned: asherry » Unassigned

Status: Needs review » Needs work

The last submitted patch, 1: node-type-orig-value-error-2219177.patch, failed testing.

asherry’s picture

Status: Needs work » Needs review
StatusFileSize
new530 bytes

My apologies, I realize now in node_type_form_submit it calls node_type_set_defaults to initialize defaults, therefore calling that function without a type. Here is another patch.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.