diff --git a/src/Entity/Devices/DevicePart.php b/src/Entity/Devices/DevicePart.php index 8e1157f2..110fabf7 100644 --- a/src/Entity/Devices/DevicePart.php +++ b/src/Entity/Devices/DevicePart.php @@ -78,12 +78,12 @@ class DevicePart extends AbstractDBElement * @ORM\ManyToOne(targetEntity="Device", inversedBy="parts") * @ORM\JoinColumn(name="id_device", referencedColumnName="id") */ - protected Device $device; + protected ?Device $device = null; /** * @var Part * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part") * @ORM\JoinColumn(name="id_part", referencedColumnName="id") */ - protected Part $part; + protected ?Part $part = null; } diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 74fb61bc..8f8dc17a 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -66,7 +66,7 @@ class MeasurementUnit extends AbstractPartsContainingDBElement * @ORM\Column(type="string", name="unit", nullable=true) * @Assert\Length(max=10) */ - protected string $unit; + protected ?string $unit = null; /** * @var bool Determines if the amount value associated with this unit should be treated as integer. diff --git a/src/Entity/Parts/PartTraits/OrderTrait.php b/src/Entity/Parts/PartTraits/OrderTrait.php index e0ee8744..12bcb166 100644 --- a/src/Entity/Parts/PartTraits/OrderTrait.php +++ b/src/Entity/Parts/PartTraits/OrderTrait.php @@ -85,7 +85,7 @@ trait OrderTrait * * @ColumnSecurity(prefix="order", type="object") */ - protected Orderdetail $order_orderdetail; + protected ?Orderdetail $order_orderdetail = null; /** * Get the selected order orderdetails of this part. diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 53bedf03..0ecfd39a 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -78,7 +78,7 @@ class Currency extends AbstractStructuralDBElement * @ORM\Column(type="string") * @Assert\Currency() */ - protected string $iso_code; + protected string $iso_code = ""; /** * @ORM\OneToMany(targetEntity="Currency", mappedBy="parent", cascade={"persist"}) diff --git a/src/Services/UserCacheKeyGenerator.php b/src/Services/UserCacheKeyGenerator.php index 827479ab..66b88a7d 100644 --- a/src/Services/UserCacheKeyGenerator.php +++ b/src/Services/UserCacheKeyGenerator.php @@ -73,13 +73,9 @@ class UserCacheKeyGenerator $user = $this->security->getUser(); } - if (!$user instanceof User){ - throw new \RuntimeException('UserCacheKeyGenerator::generateKey() was called without a user, but no user is logged in!'); - } - //If the user is null, then treat it as anonymous user. //When the anonymous user is passed as user then use this path too. - if (null === $user || User::ID_ANONYMOUS === $user->getID()) { + if (null === $user || !($user instanceof User) || User::ID_ANONYMOUS === $user->getID()) { return 'user$_'.User::ID_ANONYMOUS; }