Bnomei RSS feed not working since upgrade to Kirby 4

Not sure this is the right place to post this, but I’ve just noticed that my blog feed is no longer working since I upgraded to v4. I use Bnomei Kirby 3 feed (GitHub - bnomei/kirby3-feed: Generate a RSS/JSON-Feed and Sitemap from a Pages-Collection.) to generate the feed. Nothing has changed in my RSS setup, but now (in debug mode) I get:

Kirby\Cms\Core::{closure}(): Return value must be of type string, null returned

An issue with line 64 of /kirby/config/tags.php

I’ve downloaded the plugin again, but no change. Not sure if this is an issue with Kirby, the plugin or my particular setup. Any pointers gratefully received!

Is there a stack trace?

If I understand you correctly, it’s this:

Stack frames (34)
33
TypeError 
…/kirby/config/tags.php64
32
Kirby\Cms\Core {closure}
…/kirby/src/Text/KirbyTag.php230
31
Kirby\Text\KirbyTag render
…/kirby/src/Text/KirbyTags.php43
30
Kirby\Text\KirbyTags Kirby\Text\{closure}
[internal]0
29
 preg_replace_callback
…/kirby/src/Text/KirbyTags.php39
28
Kirby\Text\KirbyTags parse
…/kirby/src/Cms/App.php857
27
Kirby\Cms\App kirbytags
…/kirby/src/Cms/App.php871
26
Kirby\Cms\App kirbytext
…/kirby/config/methods.php401
25
Kirby\Cms\Core {closure}
…/kirby/src/Content/Field.php78
24
Kirby\Content\Field __call
…/site/plugins/kirby3-feed/snippets/feed/rss.php18
23
 include
…/kirby/src/Filesystem/F.php425
22
Kirby\Filesystem\F loadIsolated
…/kirby/src/Filesystem/F.php364
21
Kirby\Filesystem\F Kirby\Filesystem\{closure}
…/kirby/src/Filesystem/F.php372
20
Kirby\Filesystem\F load
…/kirby/src/Toolkit/Tpl.php36
19
Kirby\Toolkit\Tpl load
…/kirby/src/Template/Snippet.php172
18
Kirby\Template\Snippet factory
…/kirby/config/components.php301
17
Kirby\Cms\Core {closure}
…/kirby/src/Cms/App.php1554
16
Kirby\Cms\App snippet
…/kirby/config/helpers.php531
15
 snippet
…/site/plugins/kirby3-feed/classes/Feed.php78
14
Bnomei\Feed stringFromSnippet
…/site/plugins/kirby3-feed/classes/Feed.php202
13
Bnomei\Feed feed
…/site/plugins/kirby3-feed/index.php19
12
Kirby\Cms\Pages {closure}
[internal]0
11
Closure call
…/kirby/src/Cms/HasMethods.php39
10
Kirby\Cms\Collection callMethod
…/kirby/src/Cms/Collection.php49
9
Kirby\Cms\Collection __call
…/site/templates/rss.php19
8
 include
…/kirby/src/Filesystem/F.php425
7
Kirby\Filesystem\F loadIsolated
…/kirby/src/Filesystem/F.php364
6
Kirby\Filesystem\F Kirby\Filesystem\{closure}
…/kirby/src/Filesystem/F.php372
5
Kirby\Filesystem\F load
…/kirby/src/Toolkit/Tpl.php36
4
Kirby\Toolkit\Tpl load
…/kirby/src/Template/Template.php163
3
Kirby\Template\Template render
…/kirby/src/Cms/Page.php1017
2
Kirby\Cms\Page render
…/kirby/src/Cms/App.php777
1
Kirby\Cms\App io
…/kirby/src/Cms/App.php1191
0
Kirby\Cms\App render
…/index.php5

Thank you, that is exactly what I needed.

Ok, the issue seems to be that a kirbytag you are using somewhere returns null instead of a string. Line 64 in kirby/config/tags.php points to a file kirbytag, which doesn’t seem to have a valid file and therefore returns null. But this issue is not really related to the plugin.

Looks like this is a bug in Kirby, where the tag should return an empty string instead of null.

I do have a custom kirby tag in /plugins/custom-tags/index.php (just in case this affects it)

<?php

$originalTag = Kirby\Text\KirbyTag::$types['image'];
Kirby::plugin('hicksdesign/customtags', [
		'tags' => [
			
				'svg' => [
					'html' => function($tag) {
						$file = $tag->file($tag->value());
					return svg($file);
				}
			],
							
				'image' => [
						'attr' => array_merge(
								$originalTag['attr'],
								),

						'html' => function($tag) use ($originalTag)  {

								$file = $tag->file($tag->value());
								$result = $originalTag['html']($tag);

								if (! $file === true) {
										return $result;
								}

								$pattern = '/<img.*?>/i';

								// build a new image tag with the srcset
								$image = Html::img($tag->src, [
										'width'  => $tag->width ?? $file->width(),
										'height' => $tag->height ?? $file->height(),
										'class'  => $tag->imgclass,
										'title'  => $tag->title,
										'alt'    => $tag->alt ?? ' ',
										'decoding' => 'async',
								]);

								// replace the old image tag
								$result = preg_replace($pattern, $image , $result);

								return $result;
						}
				]
		]
]);

According to the error message, it originates from the file kirbytag. I created an issue on GitHub:

Are you using the file kirbtag anywhere?

2 Likes

Are you using the file kirbtag anywhere?

As far as I can tell, it’s only referenced in the customtags.php plugin above

Hm, but this customtags file only has an svg and image kirbytag, while the error is thrown from the file kirbytag :thinking:

Thanks - with Kirby 4.1 this fixes the issue!

2 Likes