mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Add a test for updatePublishedAt
To avoid error when a content is re-submitted and it previously add a published date. Also, fix the `testPostSameEntry`
This commit is contained in:
parent
b236d3f627
commit
ff9f89fd23
2 changed files with 43 additions and 3 deletions
|
@ -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]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue