aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/config/config.yml1
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php9
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/Configuration.php2
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php1
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php42
6 files changed, 55 insertions, 2 deletions
diff --git a/app/config/config.yml b/app/config/config.yml
index 5127c8cf..a56cbdd9 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -50,6 +50,7 @@ wallabag_core:
50 rss_limit: 50 50 rss_limit: 50
51 reading_speed: 1 51 reading_speed: 1
52 cache_lifetime: 10 52 cache_lifetime: 10
53 fetching_error_message: "wallabag can't retrieve contents for this article. Please report this issue to us."
53 54
54wallabag_user: 55wallabag_user:
55 registration_enabled: "%fosuser_registration%" 56 registration_enabled: "%fosuser_registration%"
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 3b28e635..97bb3d12 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -330,6 +330,15 @@ class EntryController extends Controller
330 330
331 $this->updateEntry($entry, 'entry_reloaded'); 331 $this->updateEntry($entry, 'entry_reloaded');
332 332
333 // if refreshing entry failed, don't save it
334 if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) {
335 $bag = $this->get('session')->getFlashBag();
336 $bag->clear();
337 $bag->add('notice', 'flashes.entry.notice.entry_reloaded_failed');
338
339 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
340 }
341
333 $em = $this->getDoctrine()->getManager(); 342 $em = $this->getDoctrine()->getManager();
334 $em->persist($entry); 343 $em->persist($entry);
335 $em->flush(); 344 $em->flush();
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
index d8141eea..3a3da024 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
@@ -39,6 +39,8 @@ class Configuration implements ConfigurationInterface
39 ->integerNode('cache_lifetime') 39 ->integerNode('cache_lifetime')
40 ->defaultValue(10) 40 ->defaultValue(10)
41 ->end() 41 ->end()
42 ->scalarNode('fetching_error_message')
43 ->end()
42 ->end() 44 ->end()
43 ; 45 ;
44 46
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
index 0cbde908..b4992d54 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
@@ -23,6 +23,7 @@ class WallabagCoreExtension extends Extension
23 $container->setParameter('wallabag_core.version', $config['version']); 23 $container->setParameter('wallabag_core.version', $config['version']);
24 $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); 24 $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']);
25 $container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']); 25 $container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']);
26 $container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']);
26 27
27 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 28 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
28 $loader->load('services.yml'); 29 $loader->load('services.yml');
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index a4b727f4..614488a6 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -40,7 +40,7 @@ services:
40 class: Graby\Graby 40 class: Graby\Graby
41 arguments: 41 arguments:
42 - 42 -
43 error_message: "wallabag can't retrieve contents for this article. Please report this issue to us." 43 error_message: '%wallabag_core.fetching_error_message%'
44 http_client: 44 http_client:
45 user_agents: 45 user_agents:
46 'lifehacker.com': 'PHP/5.2' 46 'lifehacker.com': 'PHP/5.2'
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 9b03a519..c742c620 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -359,11 +359,51 @@ class EntryControllerTest extends WallabagCoreTestCase
359 359
360 $content = $em 360 $content = $em
361 ->getRepository('WallabagCoreBundle:Entry') 361 ->getRepository('WallabagCoreBundle:Entry')
362 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); 362 ->find($content->getId());
363 363
364 $this->assertNotEmpty($content->getContent()); 364 $this->assertNotEmpty($content->getContent());
365 } 365 }
366 366
367 /**
368 * @depends testPostNewOk
369 *
370 * This test will require an internet connection.
371 */
372 public function testReloadWithFetchingFailed()
373 {
374 $this->logInAs('admin');
375 $client = $this->getClient();
376
377 $em = $client->getContainer()
378 ->get('doctrine.orm.entity_manager');
379
380 $content = $em
381 ->getRepository('WallabagCoreBundle:Entry')
382 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
383
384 // put a known failed url
385 $content->setUrl('http://0.0.0.0/failed.html');
386 $em->persist($content);
387 $em->flush();
388
389 $client->request('GET', '/reload/'.$content->getId());
390
391 $this->assertEquals(302, $client->getResponse()->getStatusCode());
392
393 // force EntityManager to clear previous entity
394 // otherwise, retrieve the same entity will retrieve change from the previous request :0
395 $em->clear();
396 $newContent = $em
397 ->getRepository('WallabagCoreBundle:Entry')
398 ->find($content->getId());
399
400 $newContent->setUrl($this->url);
401 $em->persist($newContent);
402 $em->flush();
403
404 $this->assertNotEquals($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
405 }
406
367 public function testEdit() 407 public function testEdit()
368 { 408 {
369 $this->logInAs('admin'); 409 $this->logInAs('admin');