From 5ae6c6397c05531ce8771d93eb07d72cfa779f91 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 25 Apr 2022 13:52:49 +0200 Subject: [PATCH 1/4] storedObject: add validation in properties where it is used --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 2 ++ .../AccompanyingPeriodWorkEvaluationDocument.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 0a344236c..d740f5fe4 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -35,6 +35,7 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\SerializedName; +use Symfony\Component\Validator\Constraints as Assert; /** * Class Activity. @@ -93,6 +94,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"}) + * @Assert\Valid(traverse=true) */ private Collection $documents; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index b31225df1..fd3e43e58 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -20,6 +20,7 @@ use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; use RuntimeException; use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -88,6 +89,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct * @Serializer\Groups({"read"}) * @Serializer\Groups({"write"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) + * @Assert\Valid(traverse=true) */ private ?StoredObject $storedObject = null; From 3f475035286ff4022100184561c8dfa5a24115d1 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 26 Apr 2022 11:53:17 +0200 Subject: [PATCH 2/4] storedObject: allow for null data in storedObject --- CHANGELOG.md | 4 +++- .../Entity/StoredObject.php | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7c1c3d1f..3b54facb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [Documents] Validate storedObject and allow for null data (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/565) + * [Activity form] invert 'incoming' and 'receiving' in Activity form * [Activity form] keep the same order for 'attendee' field in new and edit form * [list with period] use "sameas" test operator to introduce requestor in list @@ -24,7 +26,7 @@ and this project adheres to * [Accompanying period work evaluations] list documents associated to a work by creation date, and then by id, from the most recent to older * [Course comment] add validationConstraint NotNull and NotBlank on comment content, to avoid sql error * [Notifications] delay the sending of notificaiton to kernel.terminate -* [Notifications / Period user change] fix the sending of notification when user changes +* [Notifications / Period user change] fix the sending of notification when user changes ## Test releases diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 78387e7fe..86bc930c6 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -149,37 +149,37 @@ class StoredObject implements AsyncFileInterface, Document return $this; } - public function setDatas(array $datas) + public function setDatas(?array $datas) { - $this->datas = $datas; + $this->datas = (array) $datas; return $this; } - public function setFilename($filename) + public function setFilename(?string $filename) { - $this->filename = $filename; + $this->filename = (string) $filename; return $this; } - public function setIv($iv) + public function setIv(?array $iv) { - $this->iv = $iv; + $this->iv = (array) $iv; return $this; } - public function setKeyInfos($keyInfos) + public function setKeyInfos(?array $keyInfos) { - $this->keyInfos = $keyInfos; + $this->keyInfos = (array) $keyInfos; return $this; } - public function setType($type) + public function setType(?string $type) { - $this->type = $type; + $this->type = (string) $type; return $this; } From 8ba70b08c4b0d5c0921a251ffd413b3988a11679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 26 Apr 2022 09:54:49 +0000 Subject: [PATCH 3/4] storedObject: remove traverse=true on assert valid --- .../AccompanyingPeriodWorkEvaluationDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index fd3e43e58..eb2a7c5dd 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -89,7 +89,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct * @Serializer\Groups({"read"}) * @Serializer\Groups({"write"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - * @Assert\Valid(traverse=true) + * @Assert\Valid() */ private ?StoredObject $storedObject = null; From 2e449260882296e6292e0033a6fb3fb5b660333f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 27 Apr 2022 09:00:47 +0200 Subject: [PATCH 4/4] fix cs --- .../AccompanyingPeriodWorkEvaluationDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index eb2a7c5dd..cf3fb8a9f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -89,7 +89,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct * @Serializer\Groups({"read"}) * @Serializer\Groups({"write"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - * @Assert\Valid() + * @Assert\Valid */ private ?StoredObject $storedObject = null;