Repository navigation
Conversation
For a nested filter map, getArray() recursed with $datasource[$k] without checking the key, which raised an "Undefined array key" warning and passed null on. A null data source switches getArray() back to the top-level input, so a missing nested field was filled from an unrelated top-level variable with the same name, and an empty nested map returned the whole input. Recurse with an empty array instead. Co-Authored-By: Claude Opus 5.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.
Summary of Changes
For a nested filter map,
Input::getArray()recurses with$datasource[$k]without checking that the key exists (and with$this->get($k, null, 'array')on the first level, which returnsnullfor a missing key). Anulldata source switchesgetArray()back to reading the top-level input, so:(new Input(['b' => '5']))->getArray(['a' => ['b' => 'int']])returns['a' => ['b' => 5]]: the missinga[b]is filled from the unrelated top-levelb;getArray(['a' => ['b' => 'int']], ['x' => 1])additionally raisesWarning: Undefined array key "a";getArray(['a' => []])withamissing returns the whole input undera.The recursion now always passes an array (
[]for a missing key), so it stays in explicit-datasource mode and missing nested fields come back asnullrun through the requested filter, like missing top-level fields in that mode.#38 reports the same warning; its fix (
$datasource[$k] ?? null) silences the warning but still recurses withnulland therefore keeps reading from the top-level input. It also targets 2.x-dev.Testing Instructions
New tests in
InputTest:testGetArrayWithMissingNestedKey()andtestGetArrayWithMissingNestedKeyAndEmptyMap()(realInputFilter). Both fail before the change and pass after it.Documentation Changes Required
docs/overview.md("Reading several values at once"): the note that nested keys must exist is replaced by the actual behaviour for missing keys.Supersedes #38
🤖 Generated with Claude Code