diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Command')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php | 19 |
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 | /** |