diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-12-29 10:09:44 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-12-29 10:09:44 +0100 |
commit | 7239082a5e290dada1d393f7a25acebb09ace2de (patch) | |
tree | 97915f7266cca85ee42a3494f0a8ae4831917366 | |
parent | 89cd670abfc77ca268a538c9323a4026fec06fc7 (diff) | |
download | wallabag-7239082a5e290dada1d393f7a25acebb09ace2de.tar.gz wallabag-7239082a5e290dada1d393f7a25acebb09ace2de.tar.zst wallabag-7239082a5e290dada1d393f7a25acebb09ace2de.zip |
Renamed uuid to uid
5 files changed, 30 insertions, 30 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php index 8761a9bb..f166a325 100644 --- a/app/DoctrineMigrations/Version20160410190541.php +++ b/app/DoctrineMigrations/Version20160410190541.php | |||
@@ -31,9 +31,9 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
31 | { | 31 | { |
32 | $entryTable = $schema->getTable($this->getTable('entry')); | 32 | $entryTable = $schema->getTable($this->getTable('entry')); |
33 | 33 | ||
34 | $this->skipIf($entryTable->hasColumn('uuid'), 'It seems that you already played this migration.'); | 34 | $this->skipIf($entryTable->hasColumn('uid'), 'It seems that you already played this migration.'); |
35 | 35 | ||
36 | $entryTable->addColumn('uuid', 'string', [ | 36 | $entryTable->addColumn('uid', 'string', [ |
37 | 'notnull' => false, | 37 | 'notnull' => false, |
38 | 'length' => 23, | 38 | 'length' => 23, |
39 | ]); | 39 | ]); |
@@ -46,7 +46,7 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
46 | public function down(Schema $schema) | 46 | public function down(Schema $schema) |
47 | { | 47 | { |
48 | $entryTable = $schema->getTable($this->getTable('entry')); | 48 | $entryTable = $schema->getTable($this->getTable('entry')); |
49 | $entryTable->dropColumn('uuid'); | 49 | $entryTable->dropColumn('uid'); |
50 | 50 | ||
51 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); | 51 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); |
52 | } | 52 | } |
diff --git a/app/DoctrineMigrations/Version20161214094403.php b/app/DoctrineMigrations/Version20161214094403.php index fc9acb5a..5948b5fa 100644 --- a/app/DoctrineMigrations/Version20161214094403.php +++ b/app/DoctrineMigrations/Version20161214094403.php | |||
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface; | |||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | 8 | use Symfony\Component\DependencyInjection\ContainerInterface; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Added index on wallabag_entry.uuid | 11 | * Added index on wallabag_entry.uid |
12 | */ | 12 | */ |
13 | class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface | 13 | class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface |
14 | { | 14 | { |
@@ -17,7 +17,7 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI | |||
17 | */ | 17 | */ |
18 | private $container; | 18 | private $container; |
19 | 19 | ||
20 | private $indexName = 'IDX_entry_uiid'; | 20 | private $indexName = 'IDX_entry_uid'; |
21 | 21 | ||
22 | public function setContainer(ContainerInterface $container = null) | 22 | public function setContainer(ContainerInterface $container = null) |
23 | { | 23 | { |
@@ -37,7 +37,7 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI | |||
37 | $entryTable = $schema->getTable($this->getTable('entry')); | 37 | $entryTable = $schema->getTable($this->getTable('entry')); |
38 | $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); | 38 | $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); |
39 | 39 | ||
40 | $entryTable->addIndex(['uuid'], $this->indexName); | 40 | $entryTable->addIndex(['uid'], $this->indexName); |
41 | } | 41 | } |
42 | 42 | ||
43 | /** | 43 | /** |
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index b03f49ed..f7398e69 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -539,8 +539,8 @@ class EntryController extends Controller | |||
539 | { | 539 | { |
540 | $this->checkUserAction($entry); | 540 | $this->checkUserAction($entry); |
541 | 541 | ||
542 | if (null === $entry->getUuid()) { | 542 | if (null === $entry->getUid()) { |
543 | $entry->generateUuid(); | 543 | $entry->generateUid(); |
544 | 544 | ||
545 | $em = $this->getDoctrine()->getManager(); | 545 | $em = $this->getDoctrine()->getManager(); |
546 | $em->persist($entry); | 546 | $em->persist($entry); |
@@ -548,7 +548,7 @@ class EntryController extends Controller | |||
548 | } | 548 | } |
549 | 549 | ||
550 | return $this->redirect($this->generateUrl('share_entry', [ | 550 | return $this->redirect($this->generateUrl('share_entry', [ |
551 | 'uuid' => $entry->getUuid(), | 551 | 'uid' => $entry->getUid(), |
552 | ])); | 552 | ])); |
553 | } | 553 | } |
554 | 554 | ||
@@ -565,7 +565,7 @@ class EntryController extends Controller | |||
565 | { | 565 | { |
566 | $this->checkUserAction($entry); | 566 | $this->checkUserAction($entry); |
567 | 567 | ||
568 | $entry->cleanUuid(); | 568 | $entry->cleanUid(); |
569 | 569 | ||
570 | $em = $this->getDoctrine()->getManager(); | 570 | $em = $this->getDoctrine()->getManager(); |
571 | $em->persist($entry); | 571 | $em->persist($entry); |
@@ -581,7 +581,7 @@ class EntryController extends Controller | |||
581 | * | 581 | * |
582 | * @param Entry $entry | 582 | * @param Entry $entry |
583 | * | 583 | * |
584 | * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry") | 584 | * @Route("/share/{uid}", requirements={"uid" = ".+"}, name="share_entry") |
585 | * @Cache(maxage="25200", smaxage="25200", public=true) | 585 | * @Cache(maxage="25200", smaxage="25200", public=true) |
586 | * | 586 | * |
587 | * @return \Symfony\Component\HttpFoundation\Response | 587 | * @return \Symfony\Component\HttpFoundation\Response |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 4c9d518f..7276b437 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -24,7 +24,7 @@ use Wallabag\AnnotationBundle\Entity\Annotation; | |||
24 | * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}, | 24 | * options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"}, |
25 | * indexes={ | 25 | * indexes={ |
26 | * @ORM\Index(name="created_at", columns={"created_at"}), | 26 | * @ORM\Index(name="created_at", columns={"created_at"}), |
27 | * @ORM\Index(name="uuid", columns={"uuid"}) | 27 | * @ORM\Index(name="uid", columns={"uid"}) |
28 | * } | 28 | * } |
29 | * ) | 29 | * ) |
30 | * @ORM\HasLifecycleCallbacks() | 30 | * @ORM\HasLifecycleCallbacks() |
@@ -47,11 +47,11 @@ class Entry | |||
47 | /** | 47 | /** |
48 | * @var string | 48 | * @var string |
49 | * | 49 | * |
50 | * @ORM\Column(name="uuid", type="string", length=23, nullable=true) | 50 | * @ORM\Column(name="uid", type="string", length=23, nullable=true) |
51 | * | 51 | * |
52 | * @Groups({"entries_for_user", "export_all"}) | 52 | * @Groups({"entries_for_user", "export_all"}) |
53 | */ | 53 | */ |
54 | private $uuid; | 54 | private $uid; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * @var string | 57 | * @var string |
@@ -652,34 +652,34 @@ class Entry | |||
652 | /** | 652 | /** |
653 | * @return string | 653 | * @return string |
654 | */ | 654 | */ |
655 | public function getUuid() | 655 | public function getUid() |
656 | { | 656 | { |
657 | return $this->uuid; | 657 | return $this->uid; |
658 | } | 658 | } |
659 | 659 | ||
660 | /** | 660 | /** |
661 | * @param string $uuid | 661 | * @param string $uid |
662 | * | 662 | * |
663 | * @return Entry | 663 | * @return Entry |
664 | */ | 664 | */ |
665 | public function setUuid($uuid) | 665 | public function setUid($uid) |
666 | { | 666 | { |
667 | $this->uuid = $uuid; | 667 | $this->uid = $uid; |
668 | 668 | ||
669 | return $this; | 669 | return $this; |
670 | } | 670 | } |
671 | 671 | ||
672 | public function generateUuid() | 672 | public function generateUid() |
673 | { | 673 | { |
674 | if (null === $this->uuid) { | 674 | if (null === $this->uid) { |
675 | // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter | 675 | // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter |
676 | $this->uuid = uniqid('', true); | 676 | $this->uid = uniqid('', true); |
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | public function cleanUuid() | 680 | public function cleanUid() |
681 | { | 681 | { |
682 | $this->uuid = null; | 682 | $this->uid = null; |
683 | } | 683 | } |
684 | 684 | ||
685 | /** | 685 | /** |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index c347cca5..06ed2db6 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -810,15 +810,15 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
810 | ->getRepository('WallabagCoreBundle:Entry') | 810 | ->getRepository('WallabagCoreBundle:Entry') |
811 | ->findOneByUser($this->getLoggedInUserId()); | 811 | ->findOneByUser($this->getLoggedInUserId()); |
812 | 812 | ||
813 | // no uuid | 813 | // no uid |
814 | $client->request('GET', '/share/'.$content->getUuid()); | 814 | $client->request('GET', '/share/'.$content->getUid()); |
815 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 815 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
816 | 816 | ||
817 | // generating the uuid | 817 | // generating the uid |
818 | $client->request('GET', '/share/'.$content->getId()); | 818 | $client->request('GET', '/share/'.$content->getId()); |
819 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 819 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
820 | 820 | ||
821 | // follow link with uuid | 821 | // follow link with uid |
822 | $crawler = $client->followRedirect(); | 822 | $crawler = $client->followRedirect(); |
823 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 823 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
824 | $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); | 824 | $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); |
@@ -832,7 +832,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
832 | 832 | ||
833 | // sharing is now disabled | 833 | // sharing is now disabled |
834 | $client->getContainer()->get('craue_config')->set('share_public', 0); | 834 | $client->getContainer()->get('craue_config')->set('share_public', 0); |
835 | $client->request('GET', '/share/'.$content->getUuid()); | 835 | $client->request('GET', '/share/'.$content->getUid()); |
836 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 836 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
837 | 837 | ||
838 | $client->request('GET', '/view/'.$content->getId()); | 838 | $client->request('GET', '/view/'.$content->getId()); |
@@ -843,7 +843,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
843 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 843 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
844 | 844 | ||
845 | // share is now disable | 845 | // share is now disable |
846 | $client->request('GET', '/share/'.$content->getUuid()); | 846 | $client->request('GET', '/share/'.$content->getUid()); |
847 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 847 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
848 | } | 848 | } |
849 | 849 | ||