mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-08 15:02:23 +00:00
Renamed uuid to uid
This commit is contained in:
parent
89cd670abf
commit
7239082a5e
5 changed files with 30 additions and 30 deletions
|
@ -31,9 +31,9 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
|
||||||
{
|
{
|
||||||
$entryTable = $schema->getTable($this->getTable('entry'));
|
$entryTable = $schema->getTable($this->getTable('entry'));
|
||||||
|
|
||||||
$this->skipIf($entryTable->hasColumn('uuid'), 'It seems that you already played this migration.');
|
$this->skipIf($entryTable->hasColumn('uid'), 'It seems that you already played this migration.');
|
||||||
|
|
||||||
$entryTable->addColumn('uuid', 'string', [
|
$entryTable->addColumn('uid', 'string', [
|
||||||
'notnull' => false,
|
'notnull' => false,
|
||||||
'length' => 23,
|
'length' => 23,
|
||||||
]);
|
]);
|
||||||
|
@ -46,7 +46,7 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
|
||||||
public function down(Schema $schema)
|
public function down(Schema $schema)
|
||||||
{
|
{
|
||||||
$entryTable = $schema->getTable($this->getTable('entry'));
|
$entryTable = $schema->getTable($this->getTable('entry'));
|
||||||
$entryTable->dropColumn('uuid');
|
$entryTable->dropColumn('uid');
|
||||||
|
|
||||||
$this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'");
|
$this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Added index on wallabag_entry.uuid
|
* Added index on wallabag_entry.uid
|
||||||
*/
|
*/
|
||||||
class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface
|
class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
private $container;
|
private $container;
|
||||||
|
|
||||||
private $indexName = 'IDX_entry_uiid';
|
private $indexName = 'IDX_entry_uid';
|
||||||
|
|
||||||
public function setContainer(ContainerInterface $container = null)
|
public function setContainer(ContainerInterface $container = null)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI
|
||||||
$entryTable = $schema->getTable($this->getTable('entry'));
|
$entryTable = $schema->getTable($this->getTable('entry'));
|
||||||
$this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
|
$this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
|
||||||
|
|
||||||
$entryTable->addIndex(['uuid'], $this->indexName);
|
$entryTable->addIndex(['uid'], $this->indexName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -539,8 +539,8 @@ class EntryController extends Controller
|
||||||
{
|
{
|
||||||
$this->checkUserAction($entry);
|
$this->checkUserAction($entry);
|
||||||
|
|
||||||
if (null === $entry->getUuid()) {
|
if (null === $entry->getUid()) {
|
||||||
$entry->generateUuid();
|
$entry->generateUid();
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
|
@ -548,7 +548,7 @@ class EntryController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('share_entry', [
|
return $this->redirect($this->generateUrl('share_entry', [
|
||||||
'uuid' => $entry->getUuid(),
|
'uid' => $entry->getUid(),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ class EntryController extends Controller
|
||||||
{
|
{
|
||||||
$this->checkUserAction($entry);
|
$this->checkUserAction($entry);
|
||||||
|
|
||||||
$entry->cleanUuid();
|
$entry->cleanUid();
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
|
@ -581,7 +581,7 @@ class EntryController extends Controller
|
||||||
*
|
*
|
||||||
* @param Entry $entry
|
* @param Entry $entry
|
||||||
*
|
*
|
||||||
* @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry")
|
* @Route("/share/{uid}", requirements={"uid" = ".+"}, name="share_entry")
|
||||||
* @Cache(maxage="25200", smaxage="25200", public=true)
|
* @Cache(maxage="25200", smaxage="25200", public=true)
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
|
|
@ -24,7 +24,7 @@ use Wallabag\AnnotationBundle\Entity\Annotation;
|
||||||
* options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"},
|
* options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"},
|
||||||
* indexes={
|
* indexes={
|
||||||
* @ORM\Index(name="created_at", columns={"created_at"}),
|
* @ORM\Index(name="created_at", columns={"created_at"}),
|
||||||
* @ORM\Index(name="uuid", columns={"uuid"})
|
* @ORM\Index(name="uid", columns={"uid"})
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
|
@ -47,11 +47,11 @@ class Entry
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(name="uuid", type="string", length=23, nullable=true)
|
* @ORM\Column(name="uid", type="string", length=23, nullable=true)
|
||||||
*
|
*
|
||||||
* @Groups({"entries_for_user", "export_all"})
|
* @Groups({"entries_for_user", "export_all"})
|
||||||
*/
|
*/
|
||||||
private $uuid;
|
private $uid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -652,34 +652,34 @@ class Entry
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUuid()
|
public function getUid()
|
||||||
{
|
{
|
||||||
return $this->uuid;
|
return $this->uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $uuid
|
* @param string $uid
|
||||||
*
|
*
|
||||||
* @return Entry
|
* @return Entry
|
||||||
*/
|
*/
|
||||||
public function setUuid($uuid)
|
public function setUid($uid)
|
||||||
{
|
{
|
||||||
$this->uuid = $uuid;
|
$this->uid = $uid;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateUuid()
|
public function generateUid()
|
||||||
{
|
{
|
||||||
if (null === $this->uuid) {
|
if (null === $this->uid) {
|
||||||
// @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter
|
// @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter
|
||||||
$this->uuid = uniqid('', true);
|
$this->uid = uniqid('', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanUuid()
|
public function cleanUid()
|
||||||
{
|
{
|
||||||
$this->uuid = null;
|
$this->uid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -810,15 +810,15 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
->getRepository('WallabagCoreBundle:Entry')
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
->findOneByUser($this->getLoggedInUserId());
|
->findOneByUser($this->getLoggedInUserId());
|
||||||
|
|
||||||
// no uuid
|
// no uid
|
||||||
$client->request('GET', '/share/'.$content->getUuid());
|
$client->request('GET', '/share/'.$content->getUid());
|
||||||
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
// generating the uuid
|
// generating the uid
|
||||||
$client->request('GET', '/share/'.$content->getId());
|
$client->request('GET', '/share/'.$content->getId());
|
||||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
// follow link with uuid
|
// follow link with uid
|
||||||
$crawler = $client->followRedirect();
|
$crawler = $client->followRedirect();
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
$this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
|
$this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
|
||||||
|
@ -832,7 +832,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
|
|
||||||
// sharing is now disabled
|
// sharing is now disabled
|
||||||
$client->getContainer()->get('craue_config')->set('share_public', 0);
|
$client->getContainer()->get('craue_config')->set('share_public', 0);
|
||||||
$client->request('GET', '/share/'.$content->getUuid());
|
$client->request('GET', '/share/'.$content->getUid());
|
||||||
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
$client->request('GET', '/view/'.$content->getId());
|
$client->request('GET', '/view/'.$content->getId());
|
||||||
|
@ -843,7 +843,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
// share is now disable
|
// share is now disable
|
||||||
$client->request('GET', '/share/'.$content->getUuid());
|
$client->request('GET', '/share/'.$content->getUid());
|
||||||
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue