aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/EntryController.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-05-30 14:32:41 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-05-30 14:32:43 +0200
commit39ba51ca1af3085c3a7eb6dabdfae38c5034db1b (patch)
treefd804eba6b1ae213ce636a243955bcc485f427d1 /src/Wallabag/CoreBundle/Controller/EntryController.php
parent2c045a210ae786a9321f3cdb823ef778e772d733 (diff)
downloadwallabag-39ba51ca1af3085c3a7eb6dabdfae38c5034db1b.tar.gz
wallabag-39ba51ca1af3085c3a7eb6dabdfae38c5034db1b.tar.zst
wallabag-39ba51ca1af3085c3a7eb6dabdfae38c5034db1b.zip
Display a message when saving an entry failed
When saving an entry fail because of database error we previously just returned `false`. Now we got an error in the log and the displayed notice to the user is updated too.
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 69dfd4b1..33b5e2ad 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -23,10 +23,16 @@ class EntryController extends Controller
23 { 23 {
24 try { 24 try {
25 $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); 25 $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
26
26 $em = $this->getDoctrine()->getManager(); 27 $em = $this->getDoctrine()->getManager();
27 $em->persist($entry); 28 $em->persist($entry);
28 $em->flush(); 29 $em->flush();
29 } catch (\Exception $e) { 30 } catch (\Exception $e) {
31 $this->get('logger')->error('Error while saving an entry', [
32 'exception' => $e,
33 'entry' => $entry,
34 ]);
35
30 return false; 36 return false;
31 } 37 }
32 38
@@ -60,11 +66,12 @@ class EntryController extends Controller
60 return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); 66 return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
61 } 67 }
62 68
63 $this->updateEntry($entry); 69 $message = 'flashes.entry.notice.entry_saved';
64 $this->get('session')->getFlashBag()->add( 70 if (false === $this->updateEntry($entry)) {
65 'notice', 71 $message = 'flashes.entry.notice.entry_saved_failed';
66 'flashes.entry.notice.entry_saved' 72 }
67 ); 73
74 $this->get('session')->getFlashBag()->add('notice', $message);
68 75
69 return $this->redirect($this->generateUrl('homepage')); 76 return $this->redirect($this->generateUrl('homepage'));
70 } 77 }