mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-08 07:38:48 +01:00
Merge pull request #1887 from wallabag/v2-duplicate-bookmarklet
Fix duplicate article when added via the bookmarklet
This commit is contained in:
commit
c71d83b60c
@ -49,8 +49,7 @@ class EntryController extends Controller
|
|||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
// check for existing entry, if it exists, redirect to it with a message
|
$existingEntry = $this->checkIfEntryAlreadyExists($entry);
|
||||||
$existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
|
||||||
|
|
||||||
if (false !== $existingEntry) {
|
if (false !== $existingEntry) {
|
||||||
$this->get('session')->getFlashBag()->add(
|
$this->get('session')->getFlashBag()->add(
|
||||||
@ -86,7 +85,10 @@ class EntryController extends Controller
|
|||||||
{
|
{
|
||||||
$entry = new Entry($this->getUser());
|
$entry = new Entry($this->getUser());
|
||||||
$entry->setUrl($request->get('url'));
|
$entry->setUrl($request->get('url'));
|
||||||
$this->updateEntry($entry);
|
|
||||||
|
if (false === $this->checkIfEntryAlreadyExists($entry)) {
|
||||||
|
$this->updateEntry($entry);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('homepage'));
|
return $this->redirect($this->generateUrl('homepage'));
|
||||||
}
|
}
|
||||||
@ -420,4 +422,16 @@ class EntryController extends Controller
|
|||||||
throw $this->createAccessDeniedException('You can not access this entry.');
|
throw $this->createAccessDeniedException('You can not access this entry.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for existing entry, if it exists, redirect to it with a message.
|
||||||
|
*
|
||||||
|
* @param $entry
|
||||||
|
*
|
||||||
|
* @return array|bool
|
||||||
|
*/
|
||||||
|
private function checkIfEntryAlreadyExists($entry)
|
||||||
|
{
|
||||||
|
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user