Fixed issue #53.
This commit is contained in:
parent
0f1b2bd1ad
commit
613346841d
@ -59,17 +59,13 @@ class History extends Rails\ActiveRecord\Base
|
|||||||
$objects = new ArrayObject();
|
$objects = new ArrayObject();
|
||||||
|
|
||||||
foreach ($changes as $change) {
|
foreach ($changes as $change) {
|
||||||
// # MI: If we're redoing, why would we need a previous?
|
# If we have no previous change, this was the first change to this property
|
||||||
// # Adding this conditional so redos won't need a previous.
|
# and we have no default, so this change can't be undone.
|
||||||
// if (!$redo_change) {
|
$previous_change = $change->previous;
|
||||||
# If we have no previous change, this was the first change to this property
|
|
||||||
# and we have no default, so this change can't be undone.
|
|
||||||
$previous_change = $change->previous;
|
|
||||||
|
|
||||||
if (!$previous_change && empty($change->options()['allow_reverting_to_default'])) {
|
if (!$previous_change && empty($change->options()['allow_reverting_to_default'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
if (!$user->can_change($change->obj(), $change->column_name)) {
|
if (!$user->can_change($change->obj(), $change->column_name)) {
|
||||||
$errors[spl_object_hash($change)] = 'denied';
|
$errors[spl_object_hash($change)] = 'denied';
|
||||||
@ -104,12 +100,8 @@ class History extends Rails\ActiveRecord\Base
|
|||||||
|
|
||||||
foreach (array_reverse($stack) as $node) {
|
foreach (array_reverse($stack) as $node) {
|
||||||
$object = $node['o'];
|
$object = $node['o'];
|
||||||
// /**
|
|
||||||
// * MI: Only Pool model sets the undo (:after) callback.
|
$object->runCallbacks('undo', function() use ($node, $redo_change, $object) {
|
||||||
// * Calling it manually at the end because runCallbacks doesn't behave like in Rails.
|
|
||||||
// * TODO: fix callbacks in the framework and update this.
|
|
||||||
// */
|
|
||||||
$object->runCallbacks('undo', function() {
|
|
||||||
$changes = !empty($node['changes']) ? $node['changes'] : [];
|
$changes = !empty($node['changes']) ? $node['changes'] : [];
|
||||||
|
|
||||||
if ($changes) {
|
if ($changes) {
|
||||||
@ -137,7 +129,6 @@ class History extends Rails\ActiveRecord\Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $object->runCallbacks('after_undo');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$object->save();
|
$object->save();
|
||||||
|
Reference in New Issue
Block a user