X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FContentProxy.php;h=1ac7ad83c8ab753231ea72ec5c05db1205ae9aaf;hb=ff9f89fd2318cfb29a18d941077b5afc859bf0fe;hp=fd97e0ff8a92473b42ac97abe06f00a4656ad439;hpb=b236d3f627a21bc9b02e7726bbb72d632937a45e;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index fd97e0ff..1ac7ad83 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -122,15 +122,21 @@ class ContentProxy */ public function updatePublishedAt(Entry $entry, $value) { - $date = $value instanceof \DateTime ? $value->date : $value; + $date = $value; // is it a timestamp? if (filter_var($date, FILTER_VALIDATE_INT) !== false) { - $date = '@' . $value; + $date = '@' . $date; } try { - $entry->setPublishedAt(new \DateTime($date)); + // is it already a DateTime? + // (it's inside the try/catch in case of fail to be parse time string) + if (!$date instanceof \DateTime) { + $date = new \DateTime($date); + } + + $entry->setPublishedAt($date); } catch (\Exception $e) { $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $entry->getUrl(), 'date' => $value]); }