From ecdf1e1325f30cc6f043447dac5f600990233beb Mon Sep 17 00:00:00 2001
From: Marcos Steverlynck <26821235+massa-man@users.noreply.github.com>
Date: Sat, 27 Jan 2024 10:05:28 +0000
Subject: [PATCH] Fixed Varien_Data_Form_Filter_Date::inputFilter() and
Varien_Data_Form_Filter_Datetime::inputFilter() dealing with empty values
(#3752)
---
.all-contributorsrc | 9 +++++++++
README.md | 1 +
lib/Varien/Data/Form/Filter/Date.php | 8 ++++++++
lib/Varien/Data/Form/Filter/Datetime.php | 8 ++++++++
4 files changed, 26 insertions(+)
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 882017d2b45..1d5ef5527c7 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -1427,6 +1427,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "massa-man",
+ "name": "Marcos Steverlynck",
+ "avatar_url": "https://avatars.githubusercontent.com/u/26821235?v=4",
+ "profile": "https://www.riseart.com/",
+ "contributions": [
+ "code"
+ ]
}
],
"contributorsPerLine": 7
diff --git a/README.md b/README.md
index e40dcdfdf16..463c7f8c1ac 100644
--- a/README.md
+++ b/README.md
@@ -591,6 +591,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Kane |
Kevin Jakob |
leissbua |
+ Marcos Steverlynck |
diff --git a/lib/Varien/Data/Form/Filter/Date.php b/lib/Varien/Data/Form/Filter/Date.php
index 067058ef72a..68a76135b30 100644
--- a/lib/Varien/Data/Form/Filter/Date.php
+++ b/lib/Varien/Data/Form/Filter/Date.php
@@ -58,6 +58,10 @@ public function __construct($format = null, $locale = null)
*/
public function inputFilter($value)
{
+ if ($value === null || $value === '') {
+ return $value;
+ }
+
$filterInput = new Zend_Filter_LocalizedToNormalized([
'date_format' => $this->_dateFormat,
'locale' => $this->_locale
@@ -80,6 +84,10 @@ public function inputFilter($value)
*/
public function outputFilter($value)
{
+ if ($value === null || $value === '') {
+ return $value;
+ }
+
$filterInput = new Zend_Filter_LocalizedToNormalized([
'date_format' => Varien_Date::DATE_INTERNAL_FORMAT,
'locale' => $this->_locale
diff --git a/lib/Varien/Data/Form/Filter/Datetime.php b/lib/Varien/Data/Form/Filter/Datetime.php
index 8d1a92e8232..a27c0c1fe26 100644
--- a/lib/Varien/Data/Form/Filter/Datetime.php
+++ b/lib/Varien/Data/Form/Filter/Datetime.php
@@ -29,6 +29,10 @@ class Varien_Data_Form_Filter_Datetime extends Varien_Data_Form_Filter_Date
*/
public function inputFilter($value)
{
+ if ($value === null || $value === '') {
+ return $value;
+ }
+
$filterInput = new Zend_Filter_LocalizedToNormalized([
'date_format' => $this->_dateFormat,
'locale' => $this->_locale
@@ -51,6 +55,10 @@ public function inputFilter($value)
*/
public function outputFilter($value)
{
+ if ($value === null || $value === '') {
+ return $value;
+ }
+
$filterInput = new Zend_Filter_LocalizedToNormalized([
'date_format' => Varien_Date::DATETIME_INTERNAL_FORMAT,
'locale' => $this->_locale