Skip to content
Snippets Groups Projects
Commit 50674b4c authored by Brian Gilbert's avatar Brian Gilbert
Browse files

Issue #1224996 by katbailey: fix node_diff() only diffs modified existing...

Issue #1224996 by katbailey: fix node_diff() only diffs modified existing values, ignores newly added or removed ones.
parent 4204168b
No related branches found
Tags 8.x-1.0-alpha1
No related merge requests found
......@@ -39,6 +39,38 @@ function node_diff($old_node, $new_node) {
'#new' => explode("\n", $view_new),
);
}
elseif (isset($new_node->{$field_name}[$langcode][$delta]['value'])) {
// We have a newly input value where there was none in the previous
// version of the node.
$view_new = $new_node->{$field_name}[$langcode][$delta]['value'];
$result["{$field_name}_{$delta}"] = array(
'#name' => $instance['label'],
'#old' => '',
'#new' => explode("\n", $view_new),
);
}
elseif (isset($old_node->{$field_name}[$langcode][$delta]['value'])) {
// We have a value that has been removed from the field.
$view_old = $old_node->{$field_name}[$langcode][$delta]['value'];
$result["{$field_name}_{$delta}"] = array(
'#name' => $instance['label'],
'#old' => explode("\n", $view_old),
'#new' => '',
);
}
}
}
elseif (isset($old_node->{$field_name}[$langcode])) {
// We have a value that has been removed from the field.
foreach (array_keys($old_node->{$field_name}[$langcode]) as $delta) {
if (isset($old_node->{$field_name}[$langcode][$delta]['value'])) {
$view_old = $old_node->{$field_name}[$langcode][$delta]['value'];
$result["{$field_name}_{$delta}"] = array(
'#name' => $instance['label'],
'#old' => explode("\n", $view_old),
'#new' => '',
);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment