aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2019-07-24 16:07:38 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-07-24 16:07:38 +0200
commit51d7f62b316abfc14e770b3108edb0e3f48e38dd (patch)
tree9ceebc0956bdd03aa58e8267149cfbb585b04f8b
parent9a80dcf11e4f3ee4f4a751550afc6469e76b22d9 (diff)
downloadwallabag-51d7f62b316abfc14e770b3108edb0e3f48e38dd.tar.gz
wallabag-51d7f62b316abfc14e770b3108edb0e3f48e38dd.tar.zst
wallabag-51d7f62b316abfc14e770b3108edb0e3f48e38dd.zip
Add logger to FileCookieJar
-rw-r--r--src/Wallabag/CoreBundle/Helper/FileCookieJar.php19
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml4
2 files changed, 22 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/FileCookieJar.php b/src/Wallabag/CoreBundle/Helper/FileCookieJar.php
index 52c7f5de..9a63e949 100644
--- a/src/Wallabag/CoreBundle/Helper/FileCookieJar.php
+++ b/src/Wallabag/CoreBundle/Helper/FileCookieJar.php
@@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Helper;
5use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar; 5use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar;
6use GuzzleHttp\Cookie\SetCookie; 6use GuzzleHttp\Cookie\SetCookie;
7use GuzzleHttp\Utils; 7use GuzzleHttp\Utils;
8use Psr\Log\LoggerInterface;
8 9
9/** 10/**
10 * Overidden Cookie behavior to: 11 * Overidden Cookie behavior to:
@@ -13,6 +14,19 @@ use GuzzleHttp\Utils;
13 */ 14 */
14class FileCookieJar extends BaseFileCookieJar 15class FileCookieJar extends BaseFileCookieJar
15{ 16{
17 private $logger;
18
19 /**
20 * @param LoggerInterface $logger Only used to log info when something goes wrong
21 * @param string $cookieFile File to store the cookie data
22 */
23 public function __construct(LoggerInterface $logger, $cookieFile)
24 {
25 parent::__construct($cookieFile);
26
27 $this->logger = $logger;
28 }
29
16 /** 30 /**
17 * Saves the cookies to a file. 31 * Saves the cookies to a file.
18 * 32 *
@@ -57,6 +71,11 @@ class FileCookieJar extends BaseFileCookieJar
57 try { 71 try {
58 $data = Utils::jsonDecode($json, true); 72 $data = Utils::jsonDecode($json, true);
59 } catch (\InvalidArgumentException $e) { 73 } catch (\InvalidArgumentException $e) {
74 $this->logger->error('JSON inside the cookie is broken', [
75 'json' => $json,
76 'error_msg' => $e->getMessage(),
77 ]);
78
60 // cookie file is invalid, just ignore the exception and it'll reset the whole cookie file 79 // cookie file is invalid, just ignore the exception and it'll reset the whole cookie file
61 $data = ''; 80 $data = '';
62 } 81 }
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 169b67e5..3f3d4de7 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -83,7 +83,9 @@ services:
83 83
84 wallabag_core.guzzle.cookie_jar: 84 wallabag_core.guzzle.cookie_jar:
85 class: Wallabag\CoreBundle\Helper\FileCookieJar 85 class: Wallabag\CoreBundle\Helper\FileCookieJar
86 arguments: ["%kernel.cache_dir%/cookiejar.json"] 86 arguments:
87 - "@logger"
88 - "%kernel.cache_dir%/cookiejar.json"
87 89
88 wallabag_core.content_proxy: 90 wallabag_core.content_proxy:
89 class: Wallabag\CoreBundle\Helper\ContentProxy 91 class: Wallabag\CoreBundle\Helper\ContentProxy