]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php
Add Wallabag\CoreBundle\Helper\UrlHasher
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Command / GenerateUrlHashesCommand.php
index fb5983902ee3b13b462ad115dfff1d082b275fa0..775b04138f3028cd3754ee79f6fdede90f5446f6 100644 (file)
@@ -7,6 +7,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
+use Wallabag\CoreBundle\Helper\UrlHasher;
 use Wallabag\UserBundle\Entity\User;
 
 class GenerateUrlHashesCommand extends ContainerAwareCommand
@@ -20,18 +21,14 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
             ->setName('wallabag:generate-hashed-urls')
             ->setDescription('Generates hashed urls for each entry')
             ->setHelp('This command helps you to generates hashes of the url of each entry, to check through API if an URL is already saved')
-            ->addArgument(
-                'username',
-                InputArgument::OPTIONAL,
-                'User to process entries'
-            );
+            ->addArgument('username', InputArgument::OPTIONAL, 'User to process entries');
     }
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         $this->output = $output;
 
-        $username = $input->getArgument('username');
+        $username = (string) $input->getArgument('username');
 
         if ($username) {
             try {
@@ -69,7 +66,9 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
 
         $i = 1;
         foreach ($entries as $entry) {
-            $entry->setHashedUrl(hash('md5', $entry->getUrl()));
+            $entry->setHashedUrl(
+                UrlHasher::hashUrl($entry->getUrl())
+            );
             $em->persist($entry);
 
             if (0 === ($i % 20)) {