fix: sensitive toggle / metadata-only PUT fails on DataModel + ModelAttribute#90
Merged
Merged
Conversation
…Model + ModelAttribute
Toggling sensitive=1 on a model or field never persisted: PUT returned
200 with an empty body and the toggle reverted with "Save failed."
Two update hooks assumed every update carries the full record:
- DataModelController::hook_preprocess(update): `$o->name != $r['name']`
ran the table-rename path. A partial PUT of just {sensitive:1} omits
name, so the compare was true vs null -> renameTable($o->name, null)
throws "New table name cannot be empty" BEFORE $obj->save() persists
sensitive. Now gated on isset($r['name']) && $o->name != $r['name'].
- ModelAttributeController::hook_preprocess(update): unconditionally ran
changeColumn($tbl->name, $o->name, $r['name'], $attrs) on every update.
A metadata-only PUT (no name) tried to rename the column to an empty
name with an incomplete definition and threw. CHANGE COLUMN now gated
on isset($r['name']); the field-edit form (always sends name) is
unaffected.
The empty-200 was the swallowed hook exception. ControllerController has
no schema-altering update hook, so Controller sensitive toggles were
never affected.
Blocks enabling model/field-level sensitive-data redaction (policy reads
these flags at runtime). No schema change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Toggling
sensitive=1on a model (Settings tab) or field never persisted — PUT returned 200 with an empty body, toggle reverted with "Save failed." Two update hooks assumed every update carries the full record:$o->name != $r['name']ran the table-rename path; a partial{sensitive:1}PUT omitsname→renameTable($o->name, null)throws before$obj->save(). Gated onisset($r['name']) && ....changeColumn(...)on every update; metadata-only PUT → rename column to empty → throws. Gated onisset($r['name']).The empty-200 was the swallowed hook exception.
ControllerControllerhas no schema-altering update hook, so Controller toggles were never affected.Why it matters
Blocks enabling model/field-level sensitive-data redaction (the policy reads these flags at runtime) — a hard prerequisite for the ORB log purge.
Test plan
sensitive→ confirm DB persistssensitive=1and PUT returns a non-empty bodyname) path unchanged — schema edits still ALTERNo schema change; composer upgrade sufficient. Target v4.5.1.
🤖 Generated with Claude Code