I don’t know when this started happening, but I stumbled upon this issue some days ago in one of my plugins and just now realized it also happens in my rss-feed-generator. I am doing this in my rss php file:
$rssItem = [
'<description><![CDATA[' . $hero . "\n" . $item->intro()->kirbytext() . (($item->blockeditorfield()->isNotEmpty()) ? $item->blockeditorfield()->blocks() : $item->text()->kirbytext()) . ']]></description>'
Which worked for some time, but now I get this error:
Method Kirby\Editor\Blocks::__toString() must not throw an exception, caught Whoops\Exception\ErrorException: Undefined variable: page
I had the same thing in my komments plugin, where I try to regex URLs in an editor field using blocks(). I am not quite sure how to fix this. In the komments plugin I now use
->html() which works, but I am not sure if this is a good way of solving this.
Did something in the implementation of
Is there a stack trace or anything where exactly the error comes from? Are you using the latest versions of both Kirby and the Editor?
Unfortunately it just fails without any stacktrace. All packages are up to date. The PHP log doesn’t give any clues either:
PHP Fatal error: Method Kirby\Editor\Blocks::__toString() must not throw an exception, caught Whoops\Exception\ErrorException: Undefined variable: page in /Users/mauricerenck/Sites/me/mauricerenck/site/plugins/advanced-feed/utils/rss.php on line 0
And as soon as I change ->blocks() to ->html() it works again, but the output is bogus, because it’s just the block object with a lot of html entities.
Okay, I got it!
The error was in a snippet I used to overwrite the default image block. In there I use
$page to call one of my custom page-methods. This seems to work on my live-hosting but not on my local mamp setup.
I got a stacktrace, after I switched from php 7.3 to 7.4. on my local machine. With php 7.3 there is just silence…
So now I have to figure out, why $page isn’t available on my local machine…