aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php6
-rw-r--r--src/Wallabag/CoreBundle/Helper/UrlHasher.php13
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php3
3 files changed, 11 insertions, 11 deletions
diff --git a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
index 775b0413..8f2bff11 100644
--- a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
@@ -66,9 +66,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
66 66
67 $i = 1; 67 $i = 1;
68 foreach ($entries as $entry) { 68 foreach ($entries as $entry) {
69 $entry->setHashedUrl( 69 $entry->setHashedUrl(UrlHasher::hashUrl($entry->getUrl()));
70 UrlHasher::hashUrl($entry->getUrl())
71 );
72 $em->persist($entry); 70 $em->persist($entry);
73 71
74 if (0 === ($i % 20)) { 72 if (0 === ($i % 20)) {
@@ -87,7 +85,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
87 * 85 *
88 * @param string $username 86 * @param string $username
89 * 87 *
90 * @return \Wallabag\UserBundle\Entity\User 88 * @return User
91 */ 89 */
92 private function getUser($username) 90 private function getUser($username)
93 { 91 {
diff --git a/src/Wallabag/CoreBundle/Helper/UrlHasher.php b/src/Wallabag/CoreBundle/Helper/UrlHasher.php
index e44f219a..d123eaba 100644
--- a/src/Wallabag/CoreBundle/Helper/UrlHasher.php
+++ b/src/Wallabag/CoreBundle/Helper/UrlHasher.php
@@ -7,16 +7,17 @@ namespace Wallabag\CoreBundle\Helper;
7 */ 7 */
8class UrlHasher 8class UrlHasher
9{ 9{
10 /** @var string */
11 const ALGORITHM = 'sha1';
12
13 /** 10 /**
11 * Hash the given url using the given algorithm.
12 * Hashed url are faster to be retrieved in the database than the real url.
13 *
14 * @param string $url 14 * @param string $url
15 * @param string $algorithm
15 * 16 *
16 * @return string hashed $url 17 * @return string
17 */ 18 */
18 public static function hashUrl(string $url) 19 public static function hashUrl(string $url, $algorithm = 'sha1')
19 { 20 {
20 return hash(static::ALGORITHM, $url); 21 return hash($algorithm, urldecode($url));
21 } 22 }
22} 23}
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 37fc1000..7c4a05ed 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -351,7 +351,8 @@ class EntryRepository extends EntityRepository
351 { 351 {
352 return $this->findByHashedUrlAndUserId( 352 return $this->findByHashedUrlAndUserId(
353 UrlHasher::hashUrl($url), 353 UrlHasher::hashUrl($url),
354 $userId); 354 $userId
355 );
355 } 356 }
356 357
357 /** 358 /**