Skip to content

Commit

Permalink
Merge pull request Smile-SA#2525 from vahonc/2494-duplicate-existing-…
Browse files Browse the repository at this point in the history
…optimizer-2.10-fix

Fixes Smile-SA#2494, duplicate an existing optimizer without any date
  • Loading branch information
romainruaud authored Apr 14, 2022
2 parents 526198e + 0000150 commit b736b8b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ public function copy(OptimizerInterface $optimizer): OptimizerInterface
/** @var Optimizer $duplicate */
$duplicate = $this->optimizerFactory->create();
$duplicate->setData($optimizerData);
if ($fromDate = \DateTime::createFromFormat('Y-m-d', $optimizerData['from_date'])) {
if (isset($optimizerData['from_date'])) {
$fromDate = \DateTime::createFromFormat('Y-m-d', $optimizerData['from_date']);
// Warning: user locale dependent.
$duplicate->setFromDate($fromDate->format('m/d/Y'));
}
if ($toDate = \DateTime::createFromFormat('Y-m-d', $optimizerData['to_date'])) {
if (isset($optimizerData['to_date'])) {
$toDate = \DateTime::createFromFormat('Y-m-d', $optimizerData['to_date']);
// Warning: user locale dependent.
$duplicate->setToDate($toDate->format('m/d/Y'));
}
Expand Down

0 comments on commit b736b8b

Please sign in to comment.