News: DateTime::createFromFormat()

Created on 9 Mar 2019  路  13Comments  路  Source: nextcloud/news

Found some hints on this error by searching in the feed-io repo
At some point that line was changed:
https://github.com/alexdebril/feed-io/commit/61ef0de0c697a87520fb0a567e534c001474fcd8#diff-298a5663dcac5ac51d61a53a011ae026L58
I guess this some incompatibility issue with php. The solution might be to upgrade to feed-io 4+ but I don't know how easy that is.

DateTime::createFromFormat() expects parameter 2 to be string, array given at /nextcloud/apps/news/vendor/debril/feed-io/src/FeedIo/Adapter/Guzzle/Response.php#58

Most helpful comment

Hi,

Following @Grotax 's pull request on feed-io, I just released version 3.1.2 to fix the way feed-io creates the date from the headers.

Hope it will help.

All 13 comments

So it seems like the error is gone with a newer version of feed-io but:

  • feed-io 4+ requires php 7.1
  • some small changes are required because explicit declaration is a requirement

Feedio 4 isn't an option until nextcloud requires 7.1 I think. You can make a pull request adding the [0] to the 3.0 branch though. That should fix it.

This error also shows up in my logs, don't know if this already was a thing before the update or if it's related to the issues around feeds not updating ( #412 )

Well as it's a feed-io issue and 13.1.0 is the first release with feed-io it is definitely new. But I'm not sure that it is related to the "some feeds do no longer update" problem.

To be compliant with PSR-7, in feed-io 3, getHeader() returns an array. We have to retrieve its first element.
In feed-io 4, getHeader() returns an iterator, that's why it works out of the box.

If we use current() on getHeader(), we can fix the problem for now and it will work with feed-io.

Should this be put into a bug fix release or are you waiting on #412 to get fixed? Maybe this fixes some of the feeds that aren't working

I applied #414 but am still getting the php error reported by @Grotax. Using php 7.2, nextcloud 15.0.5 and update via cron.

Same here, I also still get the error after the patch. Environment is PHP 7.1 and Nextcloud 15.0.5 and update via cron.

i have the same error. nextcloud 15.0.5, php 7.0 and python updater. feeds getting updates if i didn't change any settings on them. enable full text end in a error

Error | PHP | DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character at /var/www/nextcloud/apps/news/lib/Fetcher/FeedFetcher.php#75 | 聽

[index] Error: Exception: DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character at <<closure>>

 0. /var/www/nextcloud/apps/news/lib/Fetcher/FeedFetcher.php line 75
    __construct("0")
 1. /var/www/nextcloud/apps/news/lib/Fetcher/Fetcher.php line 66
    fetch("feed.url", false, "0", null, null)
 2. /var/www/nextcloud/apps/news/lib/Service/FeedService.php line 228
    fetch("feed.url", false, "0", null, null)
 3. /var/www/nextcloud/apps/news/lib/Service/FeedService.php line 487
    update(77, "User", true)
 4. /var/www/nextcloud/apps/news/lib/Controller/FeedController.php line 322
    patch(77, "User", {fullTextEnabled: false})
 5. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 166
    patch(77, null, false, null, null, null, null)
 6. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 99
    executeController(OCA\News\Controller\FeedController {}, "patch")
 7. /var/www/nextcloud/lib/private/AppFramework/App.php line 118
    dispatch(OCA\News\Controller\FeedController {}, "patch")
 8. /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    main("OCA\\News\\Controller\\FeedController", "patch", OC\AppFramework\ ... {}, {feedId: "77",_route: "news.feed.patch"})
 9. <<closure>>
    __invoke({feedId: "77",_route: "news.feed.patch"})
10. /var/www/nextcloud/lib/private/Route/Router.php line 297
    call_user_func(OC\AppFramework\ ... {}, {feedId: "77",_route: "news.feed.patch"})
11. /var/www/nextcloud/lib/base.php line 987
    match("/apps/news/feeds/77")
12. /var/www/nextcloud/index.php line 42
    handleRequest()

PATCH /nextcloud/apps/news/feeds/77

The worst is, i cant even downgrate. it updates again to the new broken version

Alright thank you.
For Everyone: Please don't post any "same" or "me too" posts as we are aware of the problems and are trying to fix them. If you have new information we would like to hear it.

Hi,

Following @Grotax 's pull request on feed-io, I just released version 3.1.2 to fix the way feed-io creates the date from the headers.

Hope it will help.

Just jumping in to say that the issue is still there with News version 13.1.1
{"reqId":"VbqLvUl9odIRKQigLr0A","level":3,"time":"2019-03-14T01:00:23+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"DateTime::createFromFormat() expects parameter 2 to be string, array given at /var/www/html/custom_apps/news/vendor/debril/feed-io/src/FeedIo/Adapter/Guzzle/Response.php#58","userAgent":"--","version":"15.0.5.3","id":"5c89a7d754d16"}

I also still have these error messages, exactly like @r3pek
I now also have a bunch of DateTime::__construct(): Failed to parse time string (0) at position 0 (0): Unexpected character at /var/www/html/custom_apps/news/lib/Fetcher/FeedFetcher.php#75
errors, which seems related

Was this page helpful?
0 / 5 - 0 ratings