diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-04-10 15:37:33 +0200 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-04-10 15:37:33 +0200 |
commit | c71d83b60cdcc6b844b77414159b69568366eefa (patch) | |
tree | 1dd04c43367b29e940327b55da4489fd7c4452cd /src | |
parent | f642863ff258972df90940a59510d14b6f366883 (diff) | |
parent | 834efe84ace29c882a4a07d11446e0b20fb23d47 (diff) | |
download | wallabag-c71d83b60cdcc6b844b77414159b69568366eefa.tar.gz wallabag-c71d83b60cdcc6b844b77414159b69568366eefa.tar.zst wallabag-c71d83b60cdcc6b844b77414159b69568366eefa.zip |
Merge pull request #1887 from wallabag/v2-duplicate-bookmarklet
Fix duplicate article when added via the bookmarklet
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index fa633031..cba58858 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -49,8 +49,7 @@ class EntryController extends Controller | |||
49 | $form->handleRequest($request); | 49 | $form->handleRequest($request); |
50 | 50 | ||
51 | if ($form->isValid()) { | 51 | if ($form->isValid()) { |
52 | // check for existing entry, if it exists, redirect to it with a message | 52 | $existingEntry = $this->checkIfEntryAlreadyExists($entry); |
53 | $existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); | ||
54 | 53 | ||
55 | if (false !== $existingEntry) { | 54 | if (false !== $existingEntry) { |
56 | $this->get('session')->getFlashBag()->add( | 55 | $this->get('session')->getFlashBag()->add( |
@@ -86,7 +85,10 @@ class EntryController extends Controller | |||
86 | { | 85 | { |
87 | $entry = new Entry($this->getUser()); | 86 | $entry = new Entry($this->getUser()); |
88 | $entry->setUrl($request->get('url')); | 87 | $entry->setUrl($request->get('url')); |
89 | $this->updateEntry($entry); | 88 | |
89 | if (false === $this->checkIfEntryAlreadyExists($entry)) { | ||
90 | $this->updateEntry($entry); | ||
91 | } | ||
90 | 92 | ||
91 | return $this->redirect($this->generateUrl('homepage')); | 93 | return $this->redirect($this->generateUrl('homepage')); |
92 | } | 94 | } |
@@ -420,4 +422,16 @@ class EntryController extends Controller | |||
420 | throw $this->createAccessDeniedException('You can not access this entry.'); | 422 | throw $this->createAccessDeniedException('You can not access this entry.'); |
421 | } | 423 | } |
422 | } | 424 | } |
425 | |||
426 | /** | ||
427 | * Check for existing entry, if it exists, redirect to it with a message. | ||
428 | * | ||
429 | * @param $entry | ||
430 | * | ||
431 | * @return array|bool | ||
432 | */ | ||
433 | private function checkIfEntryAlreadyExists($entry) | ||
434 | { | ||
435 | return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); | ||
436 | } | ||
423 | } | 437 | } |