Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item::get_date: fix return type on unparsable date #753

Merged
merged 1 commit into from
Oct 23, 2022

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Oct 16, 2022

The Parse\Date::parse method can return false when it fails to parse the value and get_date will return it as is but its PHPDoc annotation does not allow returning booleans.

Let’s fix it by converting such values to null.

Fixes: fossar/selfoss#1384

The `Parse\Date::parse` method can return `false` when it fails to parse the value and `get_date` will return it as is but its PHPDoc annotation does not allow returning booleans.

Let’s fix it by converting such values to `null`.
jtojnar added a commit to fossar/selfoss that referenced this pull request Oct 19, 2022
When SimplePie is unable to parse an item update date, it will return `false`,
breaking the promise in PHPDoc. Since we do not expect it, we would try to treat
the non-null value as a an int and try to create a date object from it, which
lead to the affected sources failing to update with the following error:

    Exception: DateTimeImmutable::__construct(): Failed to parse time string (@) at position 0 (@)

I have created an upstream PR:

simplepie/simplepie#753

But until that is available, let’s work around the issue by also guarding against `false`.

Closes: #1384
@mblaney mblaney merged commit 33d85b8 into simplepie:master Oct 23, 2022
@jtojnar jtojnar deleted the patch-1 branch October 23, 2022 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure to parse date in RSS feed
3 participants