Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request from GHSA-m2x6-c2c6-pjrx
Make sure date_from and date_to are dates
  • Loading branch information
PierreRambaud committed Apr 15, 2020
2 parents 75bcf5a + b6290a6 commit c464518
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions classes/helper/HelperCalendar.php
Expand Up @@ -145,49 +145,49 @@ public function getDateFormat()
return $this->_date_format;
}

public function setDateFrom($value)
public function setDateFrom($value = '')
{
if (!isset($value) || $value == '') {
$value = date('Y-m-d', strtotime('-31 days'));
if (empty($value)) {
$value = strtotime('-31 days');
}

if (!is_string($value)) {
throw new PrestaShopException('Date must be a string');
}

$this->_date_from = $value;
$this->_date_from = date('Y-m-d', strtotime($value));

return $this;
}

public function getDateFrom()
{
if (!isset($this->_date_from)) {
$this->_date_from = date('Y-m-d', strtotime('-31 days'));
$this->setDateFrom();
}

return $this->_date_from;
}

public function setDateTo($value)
public function setDateTo($value = '')
{
if (!isset($value) || $value == '') {
$value = date('Y-m-d');
if (empty($value)) {
$value = strtotime('-31 days');
}

if (!is_string($value)) {
throw new PrestaShopException('Date must be a string');
}

$this->_date_to = $value;
$this->_date_to = date('Y-m-d', strtotime($value));

return $this;
}

public function getDateTo()
{
if (!isset($this->_date_to)) {
$this->_date_to = date('Y-m-d');
$this->setDateTo();
}

return $this->_date_to;
Expand Down

0 comments on commit c464518

Please sign in to comment.