From 7ad2fab53db4f26497e020d43fbb5991b016fa2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 13 Jun 2024 23:41:35 +0200 Subject: [PATCH] Fixed exception related that Datetimeimmutables were used were doctrine expected mutable ones this prevented the saving of parts from info providers --- src/Entity/Attachments/Attachment.php | 4 ++-- src/Entity/Attachments/AttachmentType.php | 4 ++-- src/Entity/Base/AbstractCompany.php | 4 ++-- src/Entity/Base/TimestampTrait.php | 8 ++++---- src/Entity/LogSystem/AbstractLogEntry.php | 6 +++--- src/Entity/Parts/Category.php | 4 ++-- src/Entity/Parts/Footprint.php | 4 ++-- src/Entity/Parts/InfoProviderReference.php | 6 +++--- src/Entity/Parts/MeasurementUnit.php | 4 ++-- src/Entity/Parts/Part.php | 4 ++-- src/Entity/Parts/PartLot.php | 6 +++--- src/Entity/Parts/StorageLocation.php | 4 ++-- src/Entity/PriceInformations/Currency.php | 4 ++-- src/Entity/ProjectSystem/Project.php | 4 ++-- src/Entity/UserSystem/User.php | 10 +++++----- src/Entity/UserSystem/WebauthnKey.php | 2 +- 16 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index c940bba8..a53a8d41 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -185,9 +185,9 @@ abstract class Attachment extends AbstractNamedDBElement protected ?AttachmentType $attachment_type = null; #[Groups(['attachment:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['attachment:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; public function __construct() diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 58546e6a..214f0af1 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -134,9 +134,9 @@ class AttachmentType extends AbstractStructuralDBElement protected Collection $attachments_with_type; #[Groups(['attachment_type:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['attachment_type:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; public function __construct() diff --git a/src/Entity/Base/AbstractCompany.php b/src/Entity/Base/AbstractCompany.php index 0d5b3579..13e6010a 100644 --- a/src/Entity/Base/AbstractCompany.php +++ b/src/Entity/Base/AbstractCompany.php @@ -41,9 +41,9 @@ use Symfony\Component\Validator\Constraints as Assert; abstract class AbstractCompany extends AbstractPartsContainingDBElement { #[Groups(['company:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['company:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; /** * @var string The address of the company diff --git a/src/Entity/Base/TimestampTrait.php b/src/Entity/Base/TimestampTrait.php index e6fac441..94ddf236 100644 --- a/src/Entity/Base/TimestampTrait.php +++ b/src/Entity/Base/TimestampTrait.php @@ -34,20 +34,20 @@ use Symfony\Component\Serializer\Annotation\Groups; trait TimestampTrait { /** - * @var \DateTimeInterface|null the date when this element was modified the last time + * @var \DateTime|null the date when this element was modified the last time */ #[Groups(['extended', 'full'])] #[ApiProperty(writable: false)] #[ORM\Column(name: 'last_modified', type: Types::DATETIME_MUTABLE, options: ['default' => 'CURRENT_TIMESTAMP'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; /** - * @var \DateTimeInterface|null the date when this element was created + * @var \DateTime|null the date when this element was created */ #[Groups(['extended', 'full'])] #[ApiProperty(writable: false)] #[ORM\Column(name: 'datetime_added', type: Types::DATETIME_MUTABLE, options: ['default' => 'CURRENT_TIMESTAMP'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; /** * Returns the last time when the element was modified. diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php index f1c163c5..cbccbbf0 100644 --- a/src/Entity/LogSystem/AbstractLogEntry.php +++ b/src/Entity/LogSystem/AbstractLogEntry.php @@ -55,10 +55,10 @@ abstract class AbstractLogEntry extends AbstractDBElement #[ORM\Column(type: Types::STRING)] protected string $username = ''; - /** @var \DateTimeInterface The datetime the event associated with this log entry has occured + /** @var \DateTime The datetime the event associated with this log entry has occured */ #[ORM\Column(name: 'datetime', type: Types::DATETIME_MUTABLE)] - protected \DateTimeInterface $timestamp; + protected \DateTime $timestamp; /** * @var LogLevel The priority level of the associated level. 0 is highest, 7 lowest @@ -174,7 +174,7 @@ abstract class AbstractLogEntry extends AbstractDBElement * * @return $this */ - public function setTimestamp(\DateTimeInterface $timestamp): self + public function setTimestamp(\DateTime $timestamp): self { $this->timestamp = $timestamp; diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index ed62618c..ecd609ce 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -182,9 +182,9 @@ class Category extends AbstractPartsContainingDBElement protected Collection $parameters; #[Groups(['category:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['category:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; #[Assert\Valid] #[ORM\Embedded(class: EDACategoryInfo::class)] diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 10d3c9db..02c93694 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -133,9 +133,9 @@ class Footprint extends AbstractPartsContainingDBElement protected Collection $parameters; #[Groups(['footprint:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['footprint:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; #[Assert\Valid] #[ORM\Embedded(class: EDAFootprintInfo::class)] diff --git a/src/Entity/Parts/InfoProviderReference.php b/src/Entity/Parts/InfoProviderReference.php index ea0fae7f..305c1d9b 100644 --- a/src/Entity/Parts/InfoProviderReference.php +++ b/src/Entity/Parts/InfoProviderReference.php @@ -55,7 +55,7 @@ class InfoProviderReference #[Column(type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])] #[Groups(['provider_reference:read'])] - private ?\DateTimeInterface $last_updated = null; + private ?\DateTime $last_updated = null; /** * Constructing is forbidden from outside. @@ -139,7 +139,7 @@ class InfoProviderReference $ref->provider_key = $provider_key; $ref->provider_id = $provider_id; $ref->provider_url = $provider_url; - $ref->last_updated = new \DateTimeImmutable(); + $ref->last_updated = new \DateTime(); return $ref; } @@ -154,7 +154,7 @@ class InfoProviderReference $ref->provider_key = $dto->provider_key; $ref->provider_id = $dto->provider_id; $ref->provider_url = $dto->provider_url; - $ref->last_updated = new \DateTimeImmutable(); + $ref->last_updated = new \DateTime(); return $ref; } } \ No newline at end of file diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 3ff1427b..870ad374 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -155,9 +155,9 @@ class MeasurementUnit extends AbstractPartsContainingDBElement protected Collection $parameters; #[Groups(['measurement_unit:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['measurement_unit:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; /** diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 325b143a..090eda8b 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -153,9 +153,9 @@ class Part extends AttachmentContainingDBElement protected ?Attachment $master_picture_attachment = null; #[Groups(['part:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['part:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; public function __construct() diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index 5a5ecb80..25b40d5a 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -105,13 +105,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named protected string $comment = ''; /** - * @var \DateTimeInterface|null Set a time until when the lot must be used. + * @var \DateTime|null Set a time until when the lot must be used. * Set to null, if the lot can be used indefinitely. */ #[Groups(['extended', 'full', 'import', 'part_lot:read', 'part_lot:write'])] #[ORM\Column(name: 'expiration_date', type: Types::DATETIME_MUTABLE, nullable: true)] #[Year2038BugWorkaround] - protected ?\DateTimeInterface $expiration_date = null; + protected ?\DateTime $expiration_date = null; /** * @var StorageLocation|null The storelocation of this lot @@ -246,7 +246,7 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named * * */ - public function setExpirationDate(?\DateTimeInterface $expiration_date): self + public function setExpirationDate(?\DateTime $expiration_date): self { $this->expiration_date = $expiration_date; diff --git a/src/Entity/Parts/StorageLocation.php b/src/Entity/Parts/StorageLocation.php index 8dd22a8c..c88decac 100644 --- a/src/Entity/Parts/StorageLocation.php +++ b/src/Entity/Parts/StorageLocation.php @@ -169,9 +169,9 @@ class StorageLocation extends AbstractPartsContainingDBElement protected ?Attachment $master_picture_attachment = null; #[Groups(['location:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['location:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; /******************************************************************************** diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 4df27d14..4e9a9acc 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -155,9 +155,9 @@ class Currency extends AbstractStructuralDBElement protected Collection $pricedetails; #[Groups(['currency:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['currency:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; public function __construct() diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php index d3a4b65c..e537984f 100644 --- a/src/Entity/ProjectSystem/Project.php +++ b/src/Entity/ProjectSystem/Project.php @@ -154,9 +154,9 @@ class Project extends AbstractStructuralDBElement protected Collection $parameters; #[Groups(['project:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; #[Groups(['project:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; /******************************************************************************** diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 6f2a8f25..7d8c181a 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -116,10 +116,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe protected ?int $id = null; #[Groups(['user:read'])] - protected ?\DateTimeInterface $lastModified = null; + protected ?\DateTime $lastModified = null; #[Groups(['user:read'])] - protected ?\DateTimeInterface $addedDate = null; + protected ?\DateTime $addedDate = null; /** * @var bool Determines if the user is disabled (user can not log in) @@ -317,10 +317,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe protected ?PermissionData $permissions = null; /** - * @var \DateTimeInterface|null the time until the password reset token is valid + * @var \DateTime|null the time until the password reset token is valid */ #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] - protected ?\DateTimeInterface $pw_reset_expires = null; + protected ?\DateTime $pw_reset_expires = null; /** * @var bool True if the user was created by a SAML provider (and therefore cannot change its password) @@ -535,7 +535,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe /** * Sets the datetime when the password reset token expires. */ - public function setPwResetExpires(\DateTimeInterface $pw_reset_expires): self + public function setPwResetExpires(\DateTime $pw_reset_expires): self { $this->pw_reset_expires = $pw_reset_expires; diff --git a/src/Entity/UserSystem/WebauthnKey.php b/src/Entity/UserSystem/WebauthnKey.php index abb77a96..68868fc6 100644 --- a/src/Entity/UserSystem/WebauthnKey.php +++ b/src/Entity/UserSystem/WebauthnKey.php @@ -51,7 +51,7 @@ class WebauthnKey extends BasePublicKeyCredentialSource implements TimeStampable protected ?User $user = null; #[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)] - protected ?\DateTimeInterface $last_time_used = null; + protected ?\DateTimeImmutable $last_time_used = null; public function getName(): string {