use GuzzleHttp\Cookie\FileCookieJar as BaseFileCookieJar;
use GuzzleHttp\Cookie\SetCookie;
use GuzzleHttp\Utils;
+use Psr\Log\LoggerInterface;
/**
* Overidden Cookie behavior to:
*/
class FileCookieJar extends BaseFileCookieJar
{
+ private $logger;
+
+ /**
+ * @param LoggerInterface $logger Only used to log info when something goes wrong
+ * @param string $cookieFile File to store the cookie data
+ */
+ public function __construct(LoggerInterface $logger, $cookieFile)
+ {
+ parent::__construct($cookieFile);
+
+ $this->logger = $logger;
+ }
+
/**
* Saves the cookies to a file.
*
try {
$data = Utils::jsonDecode($json, true);
} catch (\InvalidArgumentException $e) {
+ $this->logger->error('JSON inside the cookie is broken', [
+ 'json' => $json,
+ 'error_msg' => $e->getMessage(),
+ ]);
+
// cookie file is invalid, just ignore the exception and it'll reset the whole cookie file
$data = '';
}
wallabag_core.guzzle.cookie_jar:
class: Wallabag\CoreBundle\Helper\FileCookieJar
- arguments: ["%kernel.cache_dir%/cookiejar.json"]
+ arguments:
+ - "@logger"
+ - "%kernel.cache_dir%/cookiejar.json"
wallabag_core.content_proxy:
class: Wallabag\CoreBundle\Helper\ContentProxy