Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Argument 2 passed to Zend\InputFilter\BaseInputFilter::validateInputs() must be of the type array, object given #15

Merged
merged 1 commit into from
Aug 11, 2015

Conversation

weierophinney
Copy link
Member

This issue was introduced between version 2.5.1 and 2.5.3, i've switched back and forth between the two versions and I keep getting this error with 2.5.3 but not with 2.5.1
this happens when i try to validate a simple post data

Catchable fatal error: Argument 2 passed to Zend\InputFilter\BaseInputFilter::validateInputs() must be of the type array, object given, called in C:\crazylister\vendor\zendframework\zend-inputfilter\src\BaseInputFilter.php on line 221 and defined in C:\crazylister\vendor\zendframework\zend-inputfilter\src\BaseInputFilter.php on line 232

@weierophinney
Copy link
Member

It was introduced with 2.5.2, via 3575ece fixing #7.

$this->data is guaranteed to be iterable, but may, as you note, not be an actual array. As such, there are two paths forward:

  • Remove the array typehint from the $data argument.
  • Cast the $data argument to an array via iterator_to_array() prior to calling validateInputs().

I think the first would be simpler, and will get a patch out today, likely with an updated 2.5 tag immediately, and an LTS release early next week.

@weierophinney weierophinney added this to the 2.5.4 milestone Aug 11, 2015
@weierophinney weierophinney self-assigned this Aug 11, 2015
weierophinney added a commit to weierophinney/zend-inputfilter that referenced this pull request Aug 11, 2015
Per report on zendframework#15, the change made in zendframework#7 could lead to an issue if $data
is an `ArrayAccess` instance, as `validateInputs()` typehinted on `array`.
This patch adds a test for that condition, and removes the typehint.
@weierophinney
Copy link
Member

I've labelled as "BC Break" to indicate that the bug is drawing attention to an existing BC Break. The patch that I've now attached to this issue fixes it.

Per report on zendframework#15, the change made in zendframework#7 could lead to an issue if $data
is an `ArrayAccess` instance, as `validateInputs()` typehinted on `array`.
This patch adds a test for that condition, and removes the typehint.
@weierophinney
Copy link
Member

Will release with versions 2.4.7 (LTS compatibility) and 2.5.4 (5.5+ compat).

@weierophinney weierophinney merged commit 1ae32f7 into zendframework:master Aug 11, 2015
weierophinney added a commit that referenced this pull request Aug 11, 2015
- Includes new changelog version 2.5.4
- Incorporates 2.4.7 changelog
weierophinney added a commit that referenced this pull request Aug 11, 2015
weierophinney added a commit that referenced this pull request Aug 11, 2015
weierophinney added a commit to weierophinney/zend-inputfilter that referenced this pull request Sep 8, 2015
Per report on zendframework#15, the change made in zendframework#7 could lead to an issue if $data
is an `ArrayAccess` instance, as `validateInputs()` typehinted on `array`.
This patch adds a test for that condition, and removes the typehint.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant