aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-07-10 21:32:25 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-05-29 13:50:59 +0200
commitb7fa51ae7dd5fef2d9459100c88479413ddd3fb3 (patch)
tree0395f1ada65ba54578ab13b8c2398592b65bd6a1 /src
parente9579d6de9ea99522e5905e8bb827e858c8da1fc (diff)
downloadwallabag-b7fa51ae7dd5fef2d9459100c88479413ddd3fb3.tar.gz
wallabag-b7fa51ae7dd5fef2d9459100c88479413ddd3fb3.tar.zst
wallabag-b7fa51ae7dd5fef2d9459100c88479413ddd3fb3.zip
Added given_url in entry table
- Added index on entry table for given_url field - Fix tests: The previous `bit.ly` url redirected to doc.wallabag but that url doesn't exist in the fixtures. I used our own internal "redirector" to create a redirect to an url which exist in the fixtures. Also, updating current migration to use the new `WallabagMigration`.
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php36
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php1
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php1
3 files changed, 37 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 1b4367fd..62274136 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -28,7 +28,8 @@ use Wallabag\UserBundle\Entity\User;
28 * @ORM\Index(name="created_at", columns={"created_at"}), 28 * @ORM\Index(name="created_at", columns={"created_at"}),
29 * @ORM\Index(name="uid", columns={"uid"}), 29 * @ORM\Index(name="uid", columns={"uid"}),
30 * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}}) 30 * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}})
31 * } 31 * },
32 * uniqueConstraints={@ORM\UniqueConstraint(name="IDX_entry_given_url",columns={"url", "given_url", "user_id"})}
32 * ) 33 * )
33 * @ORM\HasLifecycleCallbacks() 34 * @ORM\HasLifecycleCallbacks()
34 * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())") 35 * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())")
@@ -70,6 +71,15 @@ class Entry
70 /** 71 /**
71 * @var string 72 * @var string
72 * 73 *
74 * @ORM\Column(name="given_url", type="text", nullable=true)
75 *
76 * @Groups({"entries_for_user", "export_all"})
77 */
78 private $givenUrl;
79
80 /**
81 * @var string
82 *
73 * @Assert\NotBlank() 83 * @Assert\NotBlank()
74 * @ORM\Column(name="url", type="text", nullable=true) 84 * @ORM\Column(name="url", type="text", nullable=true)
75 * 85 *
@@ -316,6 +326,30 @@ class Entry
316 } 326 }
317 327
318 /** 328 /**
329 * Set given url.
330 *
331 * @param string $givenUrl
332 *
333 * @return Entry
334 */
335 public function setGivenUrl($givenUrl)
336 {
337 $this->givenUrl = $givenUrl;
338
339 return $this;
340 }
341
342 /**
343 * Get given Url.
344 *
345 * @return string
346 */
347 public function getGivenUrl()
348 {
349 return $this->givenUrl;
350 }
351
352 /**
319 * Set url. 353 * Set url.
320 * 354 *
321 * @param string $url 355 * @param string $url
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index c6fa0d98..0d6a412d 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -76,6 +76,7 @@ class ContentProxy
76 // Not sure what are the other possible cases where this property is empty 76 // Not sure what are the other possible cases where this property is empty
77 if (empty($entry->getUrl()) && !empty($url)) { 77 if (empty($entry->getUrl()) && !empty($url)) {
78 $entry->setUrl($url); 78 $entry->setUrl($url);
79 $entry->setGivenUrl($url);
79 } 80 }
80 81
81 $this->stockEntry($entry, $content); 82 $this->stockEntry($entry, $content);
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 880e7c65..299b0b27 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -368,6 +368,7 @@ class EntryRepository extends EntityRepository
368 { 368 {
369 $res = $this->createQueryBuilder('e') 369 $res = $this->createQueryBuilder('e')
370 ->where('e.hashedUrl = :hashed_url')->setParameter('hashed_url', $hashedUrl) 370 ->where('e.hashedUrl = :hashed_url')->setParameter('hashed_url', $hashedUrl)
371 // ->orWhere('e.givenUrl = :url')->setParameter('url', $url)
371 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) 372 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
372 ->getQuery() 373 ->getQuery()
373 ->getResult(); 374 ->getResult();