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

Fix construction of sfValidatorError with an array of an array #318

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/validator/sfValidatorDate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function convertDateArrayToString($value)
// all elements must be empty or a number
foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $key) {
if (isset($value[$key]) && !ctype_digit((string) $value[$key]) && !empty($value[$key])) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break sfValidatorError::getValue() that depends on value key.

Copy link
Member

Choose a reason for hiding this comment

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

unfortunately that's not covered by the tests, as they're green anyway :(

Copy link
Contributor

Choose a reason for hiding this comment

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

That's human mutation testing. :)

}
}

Expand All @@ -164,14 +164,14 @@ protected function convertDateArrayToString($value)
(!isset($value['month']) || !$value['month'] ? 1 : 0) +
(!isset($value['day']) || !$value['day'] ? 1 : 0);
if ($empties > 0 && $empties < 3) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}
if (3 == $empties) {
return $this->getEmptyValue();
}

if (!checkdate((int) $value['month'], (int) $value['day'], (int) $value['year'])) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}

if ($this->getOption('with_time')) {
Expand All @@ -181,7 +181,7 @@ protected function convertDateArrayToString($value)
$this->isValueSet($value, 'second') && (!$this->isValueSet($value, 'minute') || !$this->isValueSet($value, 'hour'))
|| $this->isValueSet($value, 'minute') && !$this->isValueSet($value, 'hour')
) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
throw new sfValidatorError($this, 'invalid', $value);
}

$clean = sprintf(
Expand Down