From 8a6456629814039cfc623cdb279bcba06dacff50 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 1 Apr 2019 13:51:57 +0200 Subject: Use a better index for hashed_url It'll most often be used in addition to the `user_id`. Also, automatically generate the hash when saving the url. Switch from `md5` to `sha1`. --- src/Wallabag/CoreBundle/Entity/Entry.php | 5 +++-- 1 file changed, 3 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 a04f101f..faf4d259 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -26,7 +26,7 @@ use Wallabag\UserBundle\Entity\User; * indexes={ * @ORM\Index(name="created_at", columns={"created_at"}), * @ORM\Index(name="uid", columns={"uid"}), - * @ORM\Index(name="hashed_url", columns={"hashed_url"}) + * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}) * } * ) * @ORM\HasLifecycleCallbacks() @@ -79,7 +79,7 @@ class Entry /** * @var string * - * @ORM\Column(name="hashed_url", type="string", length=32, nullable=true) + * @ORM\Column(name="hashed_url", type="string", length=40, nullable=true) */ private $hashedUrl; @@ -324,6 +324,7 @@ class Entry public function setUrl($url) { $this->url = $url; + $this->hashedUrl = hash('sha1', $url); return $this; } -- cgit v1.2.3