X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FGenerateUrlHashesCommand.php;h=8f2bff114096d4a6ba24578d96d38636bb1f1fb2;hb=refs%2Fpull%2F4150%2Fhead;hp=fb5983902ee3b13b462ad115dfff1d082b275fa0;hpb=9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php index fb598390..8f2bff11 100644 --- a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php +++ b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php @@ -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,7 @@ 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)) { @@ -88,7 +85,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand * * @param string $username * - * @return \Wallabag\UserBundle\Entity\User + * @return User */ private function getUser($username) {