[Hoch] EntityMerger: #[Ignore] wirksam machen und falsy Werte korrekt mergen#531
Open
maltehuebner wants to merge 1 commit into
Open
[Hoch] EntityMerger: #[Ignore] wirksam machen und falsy Werte korrekt mergen#531maltehuebner wants to merge 1 commit into
maltehuebner wants to merge 1 commit into
Conversation
Zwei Bugs in EntityMerger::merge(): 1. isPropertyExposed() prüfte `$attr instanceof Ignore`, doch getAttributes() liefert ReflectionAttribute-Objekte – nie Ignore-Instanzen. Der Check war immer false, #[Ignore] damit wirkungslos. Jetzt: Property ist exponiert, wenn sie KEIN #[Ignore]-Attribut trägt. 2. `if ($newValue)` verwarf alle falsy Werte (0, '', false), z. B. altitude=0 auf Meereshöhe oder das Leeren eines Feldes. Jetzt: `null !== $newValue`, d. h. nur echte null-Werte (nicht gesetzte Felder) werden übersprungen. Unit-Tests (4 Fälle) ergänzt. Gesamte Unit-Suite grün. Hinweis: Die breitere Mass-Assignment-Problematik (stationCode/provider sind nicht #[Ignore], da sie beim Anlegen deserialisiert werden müssen) bleibt offen und wird über die API-Authentifizierung (#522) bzw. eine Allowlist adressiert. Refs #523 Co-Authored-By: Claude Fable 5 <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.
Behebt #523 (die beiden Korrektheits-Bugs; die breitere Mass-Assignment-Frage siehe unten).
Zwei Bugs in
EntityMerger::merge()1.
#[Ignore]war wirkungslosgetAttributes()liefertReflectionAttribute-Wrapper, nieIgnore-Instanzen — der Check schlug nie an, jede Property galt als exponiert. Neu: Property ist exponiert, wenn sie kein#[Ignore]trägt ([] === getAttributes(Ignore::class)).2. Falsy-Werte wurden verworfen
Damit ließ sich z. B.
altitude = 0(Meereshöhe) oder das Leeren eines Feldes nicht setzen. Neu:null !== $newValue— nur nicht gesetzte (null-)Felder werden übersprungen, was die korrekte Partial-Update-Semantik ist.Tests
tests/Air/Util/EntityMerger/EntityMergerTest.php— 4 Fälle: non-null kopieren, null überspringen, falsy (0/'') kopieren,#[Ignore]respektieren. Gesamte Unit-Suite grün (125 Tests).Verbleibend (nicht in diesem PR)
Die eigentliche Mass-Assignment-Lücke (
stationCode,provideretc. sind nicht#[Ignore], weil sie beim Anlegen via PUT deserialisiert werden müssen) lässt sich nicht über#[Ignore]lösen, ohne das Anlegen zu brechen. Sie wird über die API-Authentifizierung (#522, PR #530) abgedeckt; eine saubere Dauerlösung wäre eine explizite Allowlist mutierbarer Felder bzw. ein separates Update-DTO.🤖 Generated with Claude Code