Switch from DateTime to DateTimeImmutable across codebase

This commit is contained in:
Alex Cabal 2024-04-13 14:05:14 -05:00
parent 92c647f2b1
commit e55fecaaa2
35 changed files with 102 additions and 99 deletions

View file

@ -1,7 +1,7 @@
<?
use Exceptions\InvalidUrlException;
use Safe\DateTime;
use Safe\DateTimeImmutable;
use function Safe\apcu_cache_info;
use function Safe\copy;
@ -40,8 +40,8 @@ class Artwork extends Accessor{
public ?int $ArtistId = null;
public ?int $CompletedYear = null;
public bool $CompletedYearIsCirca = false;
public ?DateTime $Created = null;
public ?DateTime $Updated = null;
public ?DateTimeImmutable $Created = null;
public ?DateTimeImmutable $Updated = null;
public ?string $EbookUrl = null;
public ?int $SubmitterUserId = null;
public ?int $ReviewerUserId = null;
@ -356,7 +356,7 @@ class Artwork extends Accessor{
}
}
$now = new DateTime('now', new DateTimeZone('UTC'));
$now = new DateTimeImmutable();
$thisYear = intval($now->format('Y'));
$error = new Exceptions\ValidationException();
@ -680,7 +680,7 @@ class Artwork extends Accessor{
$this->Validate($imagePath, true);
$this->Created = new DateTime();
$this->Created = new DateTimeImmutable();
$tags = [];
foreach($this->Tags as $artworkTag){
@ -745,7 +745,7 @@ class Artwork extends Accessor{
// Manually set the updated timestamp, because if we only update the image and nothing else, the row's
// updated timestamp won't change automatically.
$this->Updated = new DateTime('now', new DateTimeZone('UTC'));
$this->Updated = new DateTimeImmutable();
$this->_ImageUrl = null;
$this->_ThumbUrl = null;
$this->_Thumb2xUrl = null;