aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Command
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2019-04-01 11:50:33 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-04-01 13:24:40 +0200
commit9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c (patch)
treeb8b37a0f8b3edd0c4db1678815d906a7b6126f31 /src/Wallabag/CoreBundle/Command
parentbfe02a0b481055bb4e799200c8daa9a0ad987c71 (diff)
downloadwallabag-9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c.tar.gz
wallabag-9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c.tar.zst
wallabag-9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c.zip
Keep url in exists endpoint
- Add migration - Use md5 instead of sha512 (we don't need security here, just a hash) - Update tests
Diffstat (limited to 'src/Wallabag/CoreBundle/Command')
-rw-r--r--src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
index fe2644f2..fb598390 100644
--- a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
@@ -45,13 +45,13 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
45 } else { 45 } else {
46 $users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll(); 46 $users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll();
47 47
48 $output->writeln(sprintf('Generating hashed urls for the %d user account entries', count($users))); 48 $output->writeln(sprintf('Generating hashed urls for "%d" users', \count($users)));
49 49
50 foreach ($users as $user) { 50 foreach ($users as $user) {
51 $output->writeln(sprintf('Processing user %s', $user->getUsername())); 51 $output->writeln(sprintf('Processing user: %s', $user->getUsername()));
52 $this->generateHashedUrls($user); 52 $this->generateHashedUrls($user);
53 } 53 }
54 $output->writeln(sprintf('Finished generated hashed urls')); 54 $output->writeln('Finished generated hashed urls');
55 } 55 }
56 56
57 return 0; 57 return 0;
@@ -67,13 +67,20 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
67 67
68 $entries = $repo->findByUser($user->getId()); 68 $entries = $repo->findByUser($user->getId());
69 69
70 $i = 1;
70 foreach ($entries as $entry) { 71 foreach ($entries as $entry) {
71 $entry->setHashedUrl(hash('sha512', $entry->getUrl())); 72 $entry->setHashedUrl(hash('md5', $entry->getUrl()));
72 $em->persist($entry); 73 $em->persist($entry);
73 $em->flush(); 74
75 if (0 === ($i % 20)) {
76 $em->flush();
77 }
78 ++$i;
74 } 79 }
75 80
76 $this->output->writeln(sprintf('Generated hashed urls for user %s', $user->getUserName())); 81 $em->flush();
82
83 $this->output->writeln(sprintf('Generated hashed urls for user: %s', $user->getUserName()));
77 } 84 }
78 85
79 /** 86 /**