aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/FileCookieJar.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/FileCookieJar.php')
-rw-r--r--src/Wallabag/CoreBundle/Helper/FileCookieJar.php19
1 files changed, 19 insertions, 0 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 }