From b7fecf3aa83b4b8161d95b0da65b841a3e948493 Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Thu, 27 Sep 2012 19:42:12 -0400 Subject: [PATCH 1/8] Improved previous fix for ZF2-558. Previous fix made implicit assumptions that could cause issues in subclasses of Element\[Select|MultiCheckbox] --- library/Zend/Form/Element/MultiCheckbox.php | 2 +- library/Zend/Form/Element/Select.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index a0ccf7a39c0..19eac3b193c 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -64,7 +64,7 @@ public function setValueOptions(array $options) $this->valueOptions = $options; // Update InArray validator haystack - if (!is_null($this->validator)) { + if (!is_null($this->validator) && $this->validator instanceof ExplodeValidator) { $validator = $this->validator->getValidator(); $validator->setHaystack($this->getValueOptionsValues()); } diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index a6850ffac42..8dd853a1462 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -83,8 +83,15 @@ public function setValueOptions(array $options) // Update InArrayValidator validator haystack if (!is_null($this->validator)) { - $validator = $this->validator instanceof InArrayValidator ? $this->validator : $this->validator->getValidator(); - $validator->setHaystack($this->getValueOptionsValues()); + if ($this->validator instanceof InArrayValidator){ + $validator = $this->validator; + } + if ($this->validator instanceof ExplodeValidator){ + $validator = $this->validator->getValidator(); + } + if (!empty($validator)){ + $validator->setHaystack($this->getValueOptionsValues()); + } } return $this; From 45bd935c542d67637dce39ede92828d3ae97de13 Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Thu, 27 Sep 2012 19:42:12 -0400 Subject: [PATCH 2/8] Improved previous fix for ZF2-558. Previous fix made implicit assumptions that could cause issues in subclasses of Element\[Select|MultiCheckbox] --- library/Zend/Form/Element/MultiCheckbox.php | 2 +- library/Zend/Form/Element/Select.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index a0ccf7a39c0..19eac3b193c 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -64,7 +64,7 @@ public function setValueOptions(array $options) $this->valueOptions = $options; // Update InArray validator haystack - if (!is_null($this->validator)) { + if (!is_null($this->validator) && $this->validator instanceof ExplodeValidator) { $validator = $this->validator->getValidator(); $validator->setHaystack($this->getValueOptionsValues()); } diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index a6850ffac42..8dd853a1462 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -83,8 +83,15 @@ public function setValueOptions(array $options) // Update InArrayValidator validator haystack if (!is_null($this->validator)) { - $validator = $this->validator instanceof InArrayValidator ? $this->validator : $this->validator->getValidator(); - $validator->setHaystack($this->getValueOptionsValues()); + if ($this->validator instanceof InArrayValidator){ + $validator = $this->validator; + } + if ($this->validator instanceof ExplodeValidator){ + $validator = $this->validator->getValidator(); + } + if (!empty($validator)){ + $validator->setHaystack($this->getValueOptionsValues()); + } } return $this; From 9aa35aa4ff413b0da276466cf1c50f8a8f0be5be Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Mon, 1 Oct 2012 18:44:52 -0400 Subject: [PATCH 3/8] Removed redundant check and fixed comment per mwop --- library/Zend/Form/Element/MultiCheckbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index 19eac3b193c..51a219b2c25 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -63,8 +63,8 @@ public function setValueOptions(array $options) { $this->valueOptions = $options; - // Update InArray validator haystack - if (!is_null($this->validator) && $this->validator instanceof ExplodeValidator) { + // Update Explode validator haystack + if ($this->validator instanceof ExplodeValidator) { $validator = $this->validator->getValidator(); $validator->setHaystack($this->getValueOptionsValues()); } From 93c204601cbee24dd4af668f9070b17e3a519870 Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Thu, 27 Sep 2012 19:42:12 -0400 Subject: [PATCH 4/8] Improved previous fix for ZF2-558. Previous fix made implicit assumptions that could cause issues in subclasses of Element\[Select|MultiCheckbox] --- library/Zend/Form/Element/MultiCheckbox.php | 2 +- library/Zend/Form/Element/Select.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index a0ccf7a39c0..19eac3b193c 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -64,7 +64,7 @@ public function setValueOptions(array $options) $this->valueOptions = $options; // Update InArray validator haystack - if (!is_null($this->validator)) { + if (!is_null($this->validator) && $this->validator instanceof ExplodeValidator) { $validator = $this->validator->getValidator(); $validator->setHaystack($this->getValueOptionsValues()); } diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index a6850ffac42..8dd853a1462 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -83,8 +83,15 @@ public function setValueOptions(array $options) // Update InArrayValidator validator haystack if (!is_null($this->validator)) { - $validator = $this->validator instanceof InArrayValidator ? $this->validator : $this->validator->getValidator(); - $validator->setHaystack($this->getValueOptionsValues()); + if ($this->validator instanceof InArrayValidator){ + $validator = $this->validator; + } + if ($this->validator instanceof ExplodeValidator){ + $validator = $this->validator->getValidator(); + } + if (!empty($validator)){ + $validator->setHaystack($this->getValueOptionsValues()); + } } return $this; From 5d37f99626243c53bd91c99f38421547f23b4f72 Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Mon, 1 Oct 2012 18:44:52 -0400 Subject: [PATCH 5/8] Removed redundant check and fixed comment per mwop --- library/Zend/Form/Element/MultiCheckbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index 19eac3b193c..51a219b2c25 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -63,8 +63,8 @@ public function setValueOptions(array $options) { $this->valueOptions = $options; - // Update InArray validator haystack - if (!is_null($this->validator) && $this->validator instanceof ExplodeValidator) { + // Update Explode validator haystack + if ($this->validator instanceof ExplodeValidator) { $validator = $this->validator->getValidator(); $validator->setHaystack($this->getValueOptionsValues()); } From 09726192d8fb4748866f4a499ceb9d95dc879158 Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Mon, 1 Oct 2012 18:54:43 -0400 Subject: [PATCH 6/8] Properly handle cases where Explode's composed validator is not InArray --- library/Zend/Form/Element/Select.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index 8dd853a1462..e2ec62d783f 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -86,7 +86,9 @@ public function setValueOptions(array $options) if ($this->validator instanceof InArrayValidator){ $validator = $this->validator; } - if ($this->validator instanceof ExplodeValidator){ + if ($this->validator instanceof ExplodeValidator + && $this->validator->getValidator instanceof InArrayValidator + ){ $validator = $this->validator->getValidator(); } if (!empty($validator)){ From 7e03fba275e44e294d31e7bf469df208b9276a7b Mon Sep 17 00:00:00 2001 From: Tim Lieberman Date: Mon, 1 Oct 2012 18:57:07 -0400 Subject: [PATCH 7/8] Properly handle cases where Explode's composed validator is not InArray --- library/Zend/Form/Element/Select.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index e2ec62d783f..dae9e83f12a 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -87,7 +87,7 @@ public function setValueOptions(array $options) $validator = $this->validator; } if ($this->validator instanceof ExplodeValidator - && $this->validator->getValidator instanceof InArrayValidator + && $this->validator->getValidator() instanceof InArrayValidator ){ $validator = $this->validator->getValidator(); } From b92fb11aa29cc895ce33faabbe32729cad28e732 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 2 Oct 2012 08:22:52 -0500 Subject: [PATCH 8/8] [#2438] CS fixes - Trailing whitespace --- library/Zend/Form/Element/Select.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Form/Element/Select.php b/library/Zend/Form/Element/Select.php index dae9e83f12a..22895a6a16b 100644 --- a/library/Zend/Form/Element/Select.php +++ b/library/Zend/Form/Element/Select.php @@ -86,7 +86,7 @@ public function setValueOptions(array $options) if ($this->validator instanceof InArrayValidator){ $validator = $this->validator; } - if ($this->validator instanceof ExplodeValidator + if ($this->validator instanceof ExplodeValidator && $this->validator->getValidator() instanceof InArrayValidator ){ $validator = $this->validator->getValidator();