aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2019-04-01 13:51:57 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-04-01 13:51:57 +0200
commit8a6456629814039cfc623cdb279bcba06dacff50 (patch)
treeb3ae2459651b6ad085588fca0c624c6df554deb3 /src/Wallabag
parent9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c (diff)
downloadwallabag-8a6456629814039cfc623cdb279bcba06dacff50.tar.gz
wallabag-8a6456629814039cfc623cdb279bcba06dacff50.tar.zst
wallabag-8a6456629814039cfc623cdb279bcba06dacff50.zip
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`.
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php2
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php1
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php5
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php2
4 files changed, 4 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
index fb598390..685e1672 100644
--- a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
@@ -69,7 +69,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
69 69
70 $i = 1; 70 $i = 1;
71 foreach ($entries as $entry) { 71 foreach ($entries as $entry) {
72 $entry->setHashedUrl(hash('md5', $entry->getUrl())); 72 $entry->setHashedUrl(hash('sha1', $entry->getUrl()));
73 $em->persist($entry); 73 $em->persist($entry);
74 74
75 if (0 === ($i % 20)) { 75 if (0 === ($i % 20)) {
diff --git a/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php
index 1b18cad6..024fcfdc 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/EntryFixtures.php
@@ -89,7 +89,6 @@ class EntryFixtures extends Fixture implements DependentFixtureInterface
89 foreach ($entries as $reference => $item) { 89 foreach ($entries as $reference => $item) {
90 $entry = new Entry($this->getReference($item['user'])); 90 $entry = new Entry($this->getReference($item['user']));
91 $entry->setUrl($item['url']); 91 $entry->setUrl($item['url']);
92 $entry->setHashedUrl(hash('md5', $item['url']));
93 $entry->setReadingTime($item['reading_time']); 92 $entry->setReadingTime($item['reading_time']);
94 $entry->setDomainName($item['domain']); 93 $entry->setDomainName($item['domain']);
95 $entry->setMimetype($item['mime']); 94 $entry->setMimetype($item['mime']);
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;
26 * indexes={ 26 * indexes={
27 * @ORM\Index(name="created_at", columns={"created_at"}), 27 * @ORM\Index(name="created_at", columns={"created_at"}),
28 * @ORM\Index(name="uid", columns={"uid"}), 28 * @ORM\Index(name="uid", columns={"uid"}),
29 * @ORM\Index(name="hashed_url", columns={"hashed_url"}) 29 * @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"})
30 * } 30 * }
31 * ) 31 * )
32 * @ORM\HasLifecycleCallbacks() 32 * @ORM\HasLifecycleCallbacks()
@@ -79,7 +79,7 @@ class Entry
79 /** 79 /**
80 * @var string 80 * @var string
81 * 81 *
82 * @ORM\Column(name="hashed_url", type="string", length=32, nullable=true) 82 * @ORM\Column(name="hashed_url", type="string", length=40, nullable=true)
83 */ 83 */
84 private $hashedUrl; 84 private $hashedUrl;
85 85
@@ -324,6 +324,7 @@ class Entry
324 public function setUrl($url) 324 public function setUrl($url)
325 { 325 {
326 $this->url = $url; 326 $this->url = $url;
327 $this->hashedUrl = hash('sha1', $url);
327 328
328 return $this; 329 return $this;
329 } 330 }
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 0534d27b..31953f12 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -248,8 +248,6 @@ class ContentProxy
248 { 248 {
249 $this->updateOriginUrl($entry, $content['url']); 249 $this->updateOriginUrl($entry, $content['url']);
250 250
251 $entry->setHashedUrl(hash('md5', $entry->getUrl()));
252
253 $this->setEntryDomainName($entry); 251 $this->setEntryDomainName($entry);
254 252
255 if (!empty($content['title'])) { 253 if (!empty($content['title'])) {