From af95c09c800e8aa8ef4af053f35d506136ecd685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 28 May 2016 13:38:59 +0200 Subject: Fix the deletion of Tags/Entries relation when delete an entry Fix #2121 --- src/Wallabag/CoreBundle/Entity/Entry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 1271f1f5..84981414 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -177,7 +177,7 @@ class Entry private $user; /** - * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist", "remove"}) + * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) * @ORM\JoinTable * * @Groups({"entries_for_user", "export_all"}) -- cgit v1.2.3 From e42b13bcff41161ecdb4322dce1ef98a401482ca Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 30 May 2016 14:34:11 +0200 Subject: Change ManyToMany between entry & tag Following https://gist.github.com/Ocramius/3121916 Be sure to remove the related entity when removing an entity. Let say you have Entry -> EntryTag -> Tag. If you remove the entry: - before that commit, the EntryTag will stay (at least using SQLite). - with that commit, the related entity is removed --- src/Wallabag/CoreBundle/Entity/Entry.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 84981414..ceae78b0 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -178,7 +178,15 @@ class Entry /** * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) - * @ORM\JoinTable + * @ORM\JoinTable( + * name="entry_tag", + * joinColumns={ + * @ORM\JoinColumn(name="entry_id", referencedColumnName="id") + * }, + * inverseJoinColumns={ + * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") + * } + * ) * * @Groups({"entries_for_user", "export_all"}) */ @@ -526,13 +534,18 @@ class Entry } } - $this->tags[] = $tag; + $this->tags->add($tag); $tag->addEntry($this); } public function removeTag(Tag $tag) { + if (!$this->tags->contains($tag)) { + return; + } + $this->tags->removeElement($tag); + $tag->removeEntry($this); } /** -- cgit v1.2.3 From f3d0cb91063840f2b05c63954d3fef3e5b8943fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 10 Apr 2016 17:33:15 +0200 Subject: Share entry with a public URL --- src/Wallabag/CoreBundle/Entity/Entry.php | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index ceae78b0..3c742828 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -37,6 +37,15 @@ class Entry */ private $id; + /** + * @var int + * + * @ORM\Column(name="uuid", type="text", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $uuid; + /** * @var string * @@ -427,6 +436,8 @@ class Entry } $this->updatedAt = new \DateTime(); + + $this->generateUuid(); } /** @@ -595,4 +606,31 @@ class Entry { return $this->language; } + + /** + * @return int + */ + public function getUuid() + { + return $this->uuid; + } + + /** + * @param int $uuid + * + * @return Entry + */ + public function setUuid($uuid) + { + $this->uuid = $uuid; + + return $this; + } + + public function generateUuid() + { + if (empty($this->uuid) || is_null($this->uuid)) { + $this->uuid = uniqid(); + } + } } -- cgit v1.2.3 From a7e2218e253138ed53e18b4775dce291c78246c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 15 Apr 2016 13:42:13 +0200 Subject: Add test and fix migration --- src/Wallabag/CoreBundle/Entity/Entry.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 3c742828..a629efc7 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -630,7 +630,8 @@ class Entry public function generateUuid() { if (empty($this->uuid) || is_null($this->uuid)) { - $this->uuid = uniqid(); + // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter + $this->uuid = uniqid('', true); } } } -- cgit v1.2.3 From f1be7af446052c6fed7033664c6c6350f558961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 23 Aug 2016 16:49:12 +0200 Subject: Change share entry behavior --- src/Wallabag/CoreBundle/Entity/Entry.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index a629efc7..8c20cde2 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -436,8 +436,6 @@ class Entry } $this->updatedAt = new \DateTime(); - - $this->generateUuid(); } /** @@ -634,4 +632,9 @@ class Entry $this->uuid = uniqid('', true); } } + + public function cleanUuid() + { + $this->uuid = null; + } } -- cgit v1.2.3 From 78b3c31d7025c743c80bcc44adda21379de8f6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 24 Aug 2016 09:07:49 +0200 Subject: Change annotation for uuid field --- src/Wallabag/CoreBundle/Entity/Entry.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 8c20cde2..67c2bb43 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -38,7 +38,7 @@ class Entry private $id; /** - * @var int + * @var string * * @ORM\Column(name="uuid", type="text", nullable=true) * @@ -606,7 +606,7 @@ class Entry } /** - * @return int + * @return string */ public function getUuid() { @@ -614,7 +614,7 @@ class Entry } /** - * @param int $uuid + * @param string $uuid * * @return Entry */ -- cgit v1.2.3 From eddda878a0ec375fa738e3228a72dd01b23e0fab Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Aug 2016 22:29:36 +0200 Subject: Update test and some cleanup --- src/Wallabag/CoreBundle/Entity/Entry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 67c2bb43..4d7e001b 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -627,7 +627,7 @@ class Entry public function generateUuid() { - if (empty($this->uuid) || is_null($this->uuid)) { + if (null === $this->uuid) { // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter $this->uuid = uniqid('', true); } -- cgit v1.2.3 From 9401696fe4ac78863fa5318de9cd9765c3a139bf Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 8 Sep 2016 16:38:08 +0200 Subject: Export dates from entries --- src/Wallabag/CoreBundle/Entity/Entry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 4d7e001b..c3e6b4d5 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -101,7 +101,7 @@ class Entry * * @ORM\Column(name="created_at", type="datetime") * - * @Groups({"export_all"}) + * @Groups({"entries_for_user", "export_all"}) */ private $createdAt; @@ -110,7 +110,7 @@ class Entry * * @ORM\Column(name="updated_at", type="datetime") * - * @Groups({"export_all"}) + * @Groups({"entries_for_user", "export_all"}) */ private $updatedAt; -- cgit v1.2.3 From 6d65c0a8b089d3caa6f8e20d7935a9fe2f87d926 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 9 Sep 2016 09:36:07 +0200 Subject: Add ability to define created_at for all import At the moment only Readability & wallabag v2 import allow created_at import. Pocket removed `time_added` field from their API v2 to v3... And wallabag v1 doesn't export that value. --- src/Wallabag/CoreBundle/Entity/Entry.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index c3e6b4d5..304258a9 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -410,7 +410,22 @@ class Entry } /** - * @return string + * Set created_at. + * Only used when importing data from an other service. + * + * @param DateTime $createdAt + * + * @return Entry + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @return DateTime */ public function getCreatedAt() { @@ -418,7 +433,7 @@ class Entry } /** - * @return string + * @return DateTime */ public function getUpdatedAt() { -- cgit v1.2.3 From 8664069e1aa2fa89e17587308a03f2720c20327a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 9 Sep 2016 10:12:25 +0200 Subject: Fix DateTime & clear() --- src/Wallabag/CoreBundle/Entity/Entry.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 304258a9..a4b0d7a8 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -97,7 +97,7 @@ class Entry private $content; /** - * @var date + * @var \DateTime * * @ORM\Column(name="created_at", type="datetime") * @@ -106,7 +106,7 @@ class Entry private $createdAt; /** - * @var date + * @var \DateTime * * @ORM\Column(name="updated_at", type="datetime") * @@ -413,7 +413,7 @@ class Entry * Set created_at. * Only used when importing data from an other service. * - * @param DateTime $createdAt + * @param \DateTime $createdAt * * @return Entry */ @@ -425,7 +425,7 @@ class Entry } /** - * @return DateTime + * @return \DateTime */ public function getCreatedAt() { @@ -433,7 +433,7 @@ class Entry } /** - * @return DateTime + * @return \DateTime */ public function getUpdatedAt() { -- cgit v1.2.3 From b0458874c85060c992aa1cb78dec91ee85082b74 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 2 Oct 2016 16:06:42 +0200 Subject: Fix relations export for Entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tags & Annotations weren’t really well exported. This is now fixed (+ tests) --- src/Wallabag/CoreBundle/Entity/Entry.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index a4b0d7a8..f2da3f4d 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -196,8 +196,6 @@ class Entry * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") * } * ) - * - * @Groups({"entries_for_user", "export_all"}) */ private $tags; @@ -541,6 +539,21 @@ class Entry return $this->tags; } + /** + * @VirtualProperty + * @SerializedName("tags") + * @Groups({"entries_for_user", "export_all"}) + */ + public function getSerializedTags() + { + $data = []; + foreach ($this->tags as $tag) { + $data[] = $tag->getLabel(); + } + + return $data; + } + /** * @param Tag $tag */ -- cgit v1.2.3