Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayInput: Accept non-array input without throwing an exception #105

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

gsteel
Copy link
Member

@gsteel gsteel commented Mar 26, 2024

Description

Alters the behaviour of ArrayInput so that non-array input is deemed a validation failure instead of an exceptional condition.

Fixes #104

This could be considered a BC break, but it would never have previously been possible for a non-array value to be validated/filtered here, so it's more likely that no-one ever used this input type without wrapping its execution in a try/catch block.

Assuming users are using this input type, and they are wrapping with try, then the introduction of the IsArray validator will still provide graceful validation failure.

Signed-off-by: George Steel <george@net-glue.co.uk>
Alters the behaviour of `ArrayInput` so that non-array input is deemed a validation failure instead of an exceptional condition.

Signed-off-by: George Steel <george@net-glue.co.uk>
@Ocramius Ocramius added this to the 2.30.0 milestone Mar 26, 2024
@Ocramius Ocramius added the Bug Something isn't working label Mar 26, 2024
@Ocramius Ocramius self-assigned this Mar 26, 2024
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM :+

@@ -4,60 +4,30 @@

namespace Laminas\InputFilter;

use function gettype;
use Laminas\Validator\IsArray;
Copy link
Member

Choose a reason for hiding this comment

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

Fancy new tech :P

@Ocramius Ocramius merged commit 05b00b6 into laminas:2.30.x Mar 26, 2024
11 checks passed
@Ocramius Ocramius deleted the array-input branch March 26, 2024 17:19
@Ocramius
Copy link
Member

Marked as bug + improvement on purpose, BTW: it changes dependencies, so it can't go to a patch version

@gsteel
Copy link
Member Author

gsteel commented Mar 26, 2024

Thankyou @Ocramius 🙏

/**
* {@inheritdoc}
*/
public function resetValue()

Choose a reason for hiding this comment

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

@gsteel After removing this, default value is null now instead of empty array. It looks like a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array Input has strange behaviour
3 participants