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

Collection Input Filter fix messages #5968

Conversation

fabiocarneiro
Copy link
Contributor

All CollectionInputFilter messages are returning as a empty arrays instead of an array of messages.

Also modified the class behavior. Previously it was copying the inputs from its Inputfilter and validating the InputFilter in CollectionInputFilter, which is not necessary since it can already be done in the InputFilter itself.

To make sure this is necessary, I updated testGetDefaultInputFilter, so it can fail when there is a error in the nested CollectionInputFilter. It is failing in current master, but it will work with this hotfix.

The CollectionInputFilter should only get each element data and setting it to the InputFilter it contains, get back the validation and messages and return in its own methods.

Special thanks to @danizord, who is always helping me with those issues.

@Ocramius
Copy link
Member

Hey @fabiocarneiro, can you provide tests that back this new logic? I also expect failures from the current test suite, right?

@fabiocarneiro
Copy link
Contributor Author

@Ocramius I'll work on that. The only problem is that the messages were not working. But since i had to change the behavior of that, i went further.

@@ -80,7 +80,6 @@ public function setInputFilter($inputFilter)
}

$this->inputFilter = $inputFilter;
$this->inputs = $inputFilter->getInputs();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks line 172?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocarneiro Can you comment on this? I think @danizord raises a valid point...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney, He was talking about the old line 172, already removed. but since this line 83 was not modified, his note wasn't outdated.

@danizord
Copy link
Contributor

@fabiocarneiro It seems that you're introducing a minor behavior change. So, you should probably reopen this PR against develop.

@danizord
Copy link
Contributor

Also, @fabiocarneiro. I realised that you moved a lot of logic from CollectionInputFilter to the child InputFilter. It seems very reasonable.

Having said that, I think you can also remove the $this->collection* properties and its setters/getters in order to use the default properties and getters/setters inherited from BaseInputFilter.

@@ -109,17 +109,6 @@ public function testSetInputFilter()
$this->assertInstanceOf('Zend\InputFilter\BaseInputFilter', $this->filter->getInputFilter());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore the chmod of this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored

@@ -223,22 +201,18 @@ public function isValid()
/**
* {@inheritdoc}
*/
public function setValidationGroup($name)
public function setValidationGroup($groups)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

singular

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the change. It's better to have the same name on parent and childs

@@ -176,45 +175,24 @@ public function isValid()
return $valid;
}

$inputs = $this->validationGroup ?: array_keys($this->inputs);
$inputs = $this->validationGroup ?: array_keys($this->inputFilter->getInputs());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is unused

/*
* @var array
*/
protected $collectionInvalidInputs;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line.


if ($this->validateInputs($inputs, $data)) {
$this->collectionValidInputs[$key] = $this->validInputs;
if ($this->inputFilter->isValid()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -300,4 +250,5 @@ public function getMessages()
{
return $this->collectionMessages;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line.

@fabiocarneiro
Copy link
Contributor Author

@Maks3w Can you review this one? Tell me what must be done to get it merged.

@Ocramius Ocramius added the bug label Apr 3, 2014
@ricardofiorani
Copy link

Will someone review this ? I need it in my project.

@weierophinney
Copy link
Member

@fabiocarneiro I'll review after you answer the open question above.

@weierophinney weierophinney added this to the 2.3.1 milestone Apr 14, 2014
@weierophinney weierophinney self-assigned this Apr 14, 2014
weierophinney added a commit that referenced this pull request Apr 14, 2014
…ilter-messages

Collection Input Filter fix messages
weierophinney added a commit that referenced this pull request Apr 14, 2014
@weierophinney weierophinney merged commit d314e45 into zendframework:master Apr 14, 2014
weierophinney added a commit that referenced this pull request Apr 14, 2014
weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request May 15, 2015
…o/hotfix-collection-input-filter-messages

Collection Input Filter fix messages
weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request May 15, 2015
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.

6 participants