After updating from 3.5 to 3.6 undefined variable error between controller and template

Hi all,

I couldn’t work on my site a while and now came back to it. So, after upgrading PHP to 8.0.13 I updated Kirby via Composer from 3.5 to 3.6. Everything went smooth but a few things broke, so I am trying to figure out what and why :wink:

Currently I struggle with the question why I get an “Undefined variable” error in my template when I try to echo the variable I defined within the corresponding controller. If I move the same variable into the template I get no error at all. I already reduced both files to this:

Controller

$info = "foobar";

Template

<?php if ($info): ?>
        <div><?= $info ?></div>
<?php endif ?>

I am probably missing something but currently I’m not seeing it. Can anyone help me look in the right direction?

Did you just define the variable or return it, too? One line from the controller doesn’t tell us much… because either the variable is not returned to the template, or maybe it is only defined under certain conditions and thus can actually be undefined.

Thank you @texnixe - a bit embarrassing but I actually forgot the return statement. :man_facepalming: :joy: