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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | node-type-orig-value-error-2219177-1.patch | 530 bytes | asherry |
| #1 | node-type-orig-value-error-2219177.patch | 528 bytes | asherry |
Comments
Comment #1
asherry commentedComment #2
asherry commentedComment #4
asherry commentedMy 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.