Repository navigation
fix: save snippets to a table that missed the 4.0.0 upgrade - #620
Merged
Merged
Conversation
…s on it, and report failed edits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A snippets table that misses the 4.0.0 upgrade lacks the
created_byandupdated_bycolumns. Every write then fails: creating a snippet returnsrest_cannot_create("The snippet could not be created."), and editing one reports success while the change is not saved. Each site's version is recorded before its table is upgraded, so a failed upgrade is not retried.Changes
save_snippet(): when an insert or update fails with an unknown-column error, the table is upgraded withDB::create_table()and the write is retried once. Any site's table, or the network table, is repaired by the first save made to it.save_snippet(): a failed update now returnsnull, so the REST route responds withrest_cannot_updateinstead of returning the unchanged snippet as if it had been saved. The snippet's lock state is set only once the row is written.DB::upgrade_after_unknown_column();DB::create_or_upgrade_tables()now returns whether every table was upgraded.Verification
DB_Test: a save to a table without the authorship columns upgrades it and succeeds, and a later edit is saved; a failed update returnsnulland leaves the stored code unchanged;create_or_upgrade_tables()reports success.updated_bydropped from the snippets table, 4.0.0 reproduces both symptoms (create returns 500, edit returns 200 without saving). With this change, create succeeds, the edit is saved, and the column is restored.