-
-
Notifications
You must be signed in to change notification settings - Fork 1
Change: do no longer default to 1800-01-01 as date for fetching feeds #15
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
Conversation
|
Hi, thanks for this. I think in principle I like this, the date way in the past was set to fetch all items no matter what in context of nextcloud/news. I'm not sure how it was before that. But just removing the lines won't do it, the date set there is used in the Result and in filtering the items and Null will not be accepted to further handling of null is needed. @SMillerDev what do you think? |
|
It was rather more elaborate back then, see upstream#340. The caller, most often FeedIo-read() already passes along the |
|
I'm not sure if I understand what you mean but anyway if you are motivated to keep working on this feel free, otherwise we can close this PR. |
|
The case for removing if (is_null($modifiedSince)) {
$modifiedSince = new DateTime('1800-01-01');
}is that the method - When it then calls the client through If any other value of |
How does a completely independent piece of code invalidate a signature? As far as I know invalidating a method signature can only happen if a method is somehow overloaded, which AFAIK isn't even possible in PHP. Do you mean to say that always setting a date makes the date parameter on the ClientInterface useless? |
|
With the code the property is not nullable, hence it does not follow the method as defined in the class or interface-signature. |
|
By that definition any if statement that sets a variable based on an earlier method parameter invalidates the method. In an academic sense that might be true, but in the real world this happens a lot. Unless this fixes a real bug I'm inclined to decline this. |
|
I think the core issue is that some feeds do not support headers. And I think a better solution to this would be to check if the remote actually supports it or not. Like in nextcloud/news#3243 |
That too, but setting an invalid header in general is not exactly useful either. The RFC states that the server should ignore invalid headers, but as you can see from the reddit example, you are quickly flagged as a ‘bad bot’. I also think that the workaround would no longer be necessary. However, I believe that this would not have been necessary in general, as the problem was homemade in my opinion, due to the original forcing to “1970-01-01”. modifiedSince is used here in two places, once to set the If-Modified-Since header to prevent unnecessary downloads, but also for Result->getItemsSince(DateTime $since = null), so that you can only request the items that would be new. I think the workaround was only needed for the latter, so that this could have been done independently of the header. You can also pass a different date to getItemsSince, so this could have been done on the client side, if I understood the problem correctly. So I would remove the forced setting of the header completely, as both the invalid header “1800-01-01” and “1970-01-01” mean the same as not setting a header. For this Result.php needs to be modified, so that $modifiedSince = null is also allowed here and in this case getItemsSince should return all items, which would also solve the problem with older items. The question would be what getModifiedSince should return here, I don't see this being changed during processing the request. So it returns the value that you have entered, unless I am missing something here.
I would leave the responsibility for whether a feed supports modifiedSince to the calling app, which also has control over the status information of the feeds. |
|
This is how I would do it: |
|
Integrated changes from @wofferl's commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where the ResponseInterface is invalidated when reading feeds that don't support HEAD requests by removing the automatic creation of a default DateTime for $modifiedSince and making it properly nullable throughout the codebase.
- Removes automatic creation of default DateTime('1800-01-01') when modifiedSince is null
- Makes Result constructor's modifiedSince parameter properly nullable with default null
- Adds null-safe handling in getItemsSince() method to return all items when no start date is provided
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/FeedIo/Reader.php | Removes forced default DateTime creation for null modifiedSince parameter |
| src/FeedIo/Reader/Result.php | Makes modifiedSince parameter nullable and adds null-safe filtering logic |
| tests/FeedIo/ReaderTest.php | Updates test expectation to match new null behavior |
Do not invalidate ResponseInterface.
|
Thanks for your contributions and inputs that is how you evolve open source projects. |
- Add logic to set the node's link from the <guid> element when isPermaLink="true" and no link is present. (#12) - Do no longer default to 1800-01-01 as date for fetching feeds (#15) - Don't set if-modified-since header when discover feeds (#19) - Analysis of relative links for the Atom feed (#10) - Implicit null deprecations fixed (#17)
Changed - Add logic to set the node's link from the <guid> element when isPermaLink="true" and no link is present. (#12) - Do no longer default to 1800-01-01 as date for fetching feeds (#15) - Don't set if-modified-since header when discover feeds (#19) Fixed - Analysis of relative links for the Atom feed (#10) - Implicit null deprecations fixed (#17)
Changed - Add logic to set the node's link from the <guid> element when isPermaLink="true" and no link is present. (#12) - Do no longer default to 1800-01-01 as date for fetching feeds (#15) - Don't set if-modified-since header when discover feeds (#19) Fixed - Analysis of relative links for the Atom feed (#10) - Implicit null deprecations fixed (#17)
Following the case from alexdebril/feed-io#415, the current method-signature of
Reader->read()invalidatesAdapter/Http/Client->getResponse()by defining a value for$modifiedSinceother than its default,null.When querying a feed that does not support HEAD-requests, it will fail. This is the current case for BlueSky. Eg., a GET-request
-- curl https://bsky.app/profile/did:plc:eclio37ymobqex2ncko63h4r/rssworks fine, adding--headgives 404-response. This should of course be a 405-response.This is the case for both the 5- and 6-major version range: When calling getResponse(), the fallback GET-request is not reached if the prior requests throws an error.