Skip to content

Commit

Permalink
Merge pull request mautic#12784 from nick-vanpraet/feature/5.x/null-p…
Browse files Browse the repository at this point in the history
…ublish-dates-on-mail-clone

Empty the (un)publish dates on email clone
  • Loading branch information
escopecz authored Oct 23, 2023
2 parents 6fb0414 + c729d44 commit d1bfac6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/bundles/EmailBundle/Entity/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class Email extends FormEntity implements VariantEntityInterface, TranslationEnt
private $emailType = 'template';

/**
* @var \DateTimeInterface
* @var \DateTimeInterface|null
*/
private $publishUp;

/**
* @var \DateTimeInterface
* @var \DateTimeInterface|null
*/
private $publishDown;

Expand Down Expand Up @@ -219,6 +219,8 @@ public function __clone()
$this->variantStartDate = null;
$this->emailType = null;
$this->sessionId = 'new_'.hash('sha1', uniqid(mt_rand()));
$this->publishUp = null;
$this->publishDown = null;
$this->clearTranslations();
$this->clearVariants();
$this->clearStats();
Expand Down
21 changes: 21 additions & 0 deletions app/bundles/EmailBundle/Tests/Entity/EmailCloneTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Mautic\EmailBundle\Tests\Entity;

use Mautic\EmailBundle\Entity\Email;
use PHPUnit\Framework\TestCase;

class EmailTest extends TestCase
{
public function testCloneResetPublishDates(): void
{
$email = new Email();
$email->setPublishUp(new \DateTime());
$email->setPublishDown(new \DateTime());
$emailClone = clone $email;
$this->assertNull($emailClone->getPublishUp());
$this->assertNull($emailClone->getPublishDown());
}
}

0 comments on commit d1bfac6

Please sign in to comment.