bnomei / kirby3-feed

Generate ATOM/JSON/RSS-Feed and XML-Sitemap from Pages-Collection
https://forum.getkirby.com/t/kirby3-feed-rss-json-sitemap/23574
MIT License
65 stars 8 forks source link

Date throws an exception because $modified is an object #7

Closed LeBenLeBen closed 5 years ago

LeBenLeBen commented 5 years ago

When using the plugin as:

echo page('blog')->children()->visible()->flip()->limit(10)->feed(array(
  'title'       => $page->feedTitle(),
  'description' => $page->feedDescription(),
  'link'        => page('blog')->url()
));

I get the following error:

Whoops\Exception\ErrorException thrown with message "date() expects parameter 2 to be integer, object given"

Stacktrace:
#17 Whoops\Exception\ErrorException in /vagrant/vendor/bnomei/kirby3-feed/snippets/feed/rss.php:9
#16 date in /vagrant/vendor/bnomei/kirby3-feed/snippets/feed/rss.php:9
#15 require in /vagrant/kirby/src/Toolkit/Tpl.php:39
#14 Kirby\Toolkit\Tpl:load in /vagrant/kirby/config/components.php:80
#13 Kirby\Cms\App:{closure} in /vagrant/kirby/src/Cms/App.php:1064
#12 Kirby\Cms\App:snippet in /vagrant/kirby/config/helpers.php:625
#11 snippet in /vagrant/vendor/bnomei/kirby3-feed/classes/Feed.php:61
#10 Bnomei\Feed:feed in /vagrant/vendor/bnomei/kirby3-feed/config.php:16
#9 Kirby\Cms\Pages:{closure} in [internal]:0
#8 Closure:call in /vagrant/kirby/src/Cms/HasMethods.php:25
#7 Kirby\Cms\Collection:callMethod in /vagrant/kirby/src/Cms/Collection.php:47
#6 Kirby\Cms\Collection:__call in /vagrant/site/templates/feed.php:6
#5 require in /vagrant/kirby/src/Toolkit/Tpl.php:39
#4 Kirby\Toolkit\Tpl:load in /vagrant/kirby/src/Cms/Template.php:164
#3 Kirby\Cms\Template:render in /vagrant/kirby/src/Cms/Page.php:1105
#2 Kirby\Cms\Page:render in /vagrant/kirby/src/Cms/App.php:516
#1 Kirby\Cms\App:io in /vagrant/kirby/src/Cms/App.php:773
#0 Kirby\Cms\App:render in /vagrant/public/index.php:18

The line causing problem is in the RSS snippet:

<lastBuildDate><?php echo \date('r', $modified) ?></lastBuildDate>

The value of $modified is:

Kirby\Cms\Field Object
(
    [date] => 2019-01-31
)

Am I doing something wrong?

LeBenLeBen commented 5 years ago

Here is the definition of my date field if that is of any interest:

date:
  label: Publication date
  type: date
  format: LL
bnomei commented 5 years ago

thanks @LeBenLeBen for submitting this issue. at first glance its a bug.

i created this plugin during k3 beta. afaik the logic of date field changed but i forgot to update this plugin. i will fix it asap. while i check for other causes can you try date('r', $modified->date()) and report back?

LeBenLeBen commented 5 years ago

Almost, it works with $modified->toDate()

bnomei commented 5 years ago

i think you found another bug: https://github.com/getkirby/kirby/issues/1446

LeBenLeBen commented 5 years ago

I guess this is solved now, thanks!