mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix another cause of inconsistency that can be triggered by bad DocActions.
Summary: An incorrect DocAction (as possible from an Undo of a non-last action) could cause RemoveRecord on an already missing record. This used to create an invalid undo, and wreak havoc when a series of DocActions later fails and needs to be reverted. To fix, consider RemoveRecord of a missing record to be a no-op. Test Plan: Includes a new test case that triggers the problem. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2717
This commit is contained in:
@@ -34,6 +34,11 @@ class DocActions(object):
|
||||
def BulkRemoveRecord(self, table_id, row_ids):
|
||||
table = self._engine.tables[table_id]
|
||||
|
||||
# Ignore records that don't exist in the table.
|
||||
row_ids = [r for r in row_ids if r in table.row_ids]
|
||||
if not row_ids:
|
||||
return
|
||||
|
||||
# Collect the undo values, and unset all values in the column (i.e. set to defaults), just to
|
||||
# make sure we don't have stale values hanging around.
|
||||
undo_values = {}
|
||||
|
||||
Reference in New Issue
Block a user