Panel errors after 3.5 update

Hi there,
I am trying to update my current work project to 3.5 (mainly due to the much improved date input), but I am getting two different error messages in the panel. I have no idea what they mean or how I could possibly debug them. Help would be much appreciated.

Error #1: "notification is not defined"
This happens on the site level of the panel, where I basically list the main pages of the site, as well as at an projects subpage where I list project subpages. It appears when I open the site:

20210106-011119_Screenshot_GoogleChrome

Error #2: "Call to a member function is() on null"
This one happens on my project subpage after I changed a field and try to save the page.
20210106-014906_Screenshot_GoogleChrome

Any ideas what could be causing these errors?

Thanks!

From which version are you updating? I saw the first error recently on a project as well, which was 3.3.x when I just threw 3.5 into it, but didn’t have the time to look into it.
Have you made sure to clear the cache, both Kirby and browser, remove the media file etc.?

Thank you Sonja. I was able to figure out these errors, but now I am stuck a a new one.

The first error was caused by a now outdated version of the Custom Add Fields plugin. The second error was caused by the breaking changes regarding hooks on the 3.4 update. Now I fixed that issue, by properly renaming the hook parameter.

But now I am stuck a at a new error message that relates to that hook and some custom methods I had set up in the hooks to handle writing to structure fields within structure fields within the pagebuilder plugin. As the pagebuilder plugin is obsolete now, I am really at loss how I can transfer the existing setup to the current version of Kirby.

Here is the error message I am getting (again after updating the page):

20210106-211700_Screenshot_GoogleChrome

Here is the hook I am using:

if ($newPage->intendedTemplate() == 'project') {

  $yamlbuilder = $newPage->eventcontextbuilder()->yaml();
  foreach ($yamlbuilder as &$eventcontextblock) {
    if($eventcontextblock['showevents'] == 'false') {
      $eventcontextblock['parsedinfo'] = '  [Alle Termine ausgeblendet]';
    } else {
      $eventcontextblock['parsedinfo'] = '';
    }

    foreach ($eventcontextblock['eventbuilder'] as &$eventblock) {
      $startdate = date('d.m.Y', strtotime($eventblock['date']));
      $time = $eventblock['time'];
      $enddate = false;

      if($eventblock['enddate'] !== '') {
        $enddate = date('d.m.Y', strtotime($eventblock['enddate']));
      }

      $parseddate = $startdate;

      if($enddate) {
        $parseddate .= ' - ' . $enddate;
      } else if ($time) {
        $parseddate .= '  ' . $time;
      }

      $eventblock['parseddate'] = $parseddate;

      $statusdivider = $eventblock['eventtype'] ? '  ' : '';
      if($eventblock['showevent'] == 'hide') {
        $eventblock['showstatus'] = $statusdivider . '[ausgeblendet]';
      } else if($eventblock['showevent'] == 'hideafter') {
        $eventblock['showstatus'] = $statusdivider . '[eingeblendet bis zum Termin]';
      } else {
        $eventblock['showstatus'] = '';
      }

    }
  }

  $newPage->update([
    'eventcontextbuilder' => Data::encode($yamlbuilder, "yaml")
  ]);

}

Here is a thread, where you @texnixe, helped me to come up with this solution, to give this some context.

I am not sure what is causing this error now and how to resolve this, as I am not quite certain what changed behind the scenes in regard to the replacement of the pagebuilder by Blocks.

Any idea how I could solve this?
Thanks!

Have you replace the pagebuilder with the blocks field?

The blocks field doesn’t store data as yaml encoded stuff but as json, so this code won’t work anymore, I think.

Yes, I have. On first glance it looks like the data is still there. But how could I make the hook work again (and have the error go away)?

If the data is transformed to JSON, coverting it to an array using yaml won’t work. I haven’t really looked into this yet, so cannot help tonight, I’m afraid.

So, simply de- and re-encoding it as JSON instead of yaml wouldn’t work, if I understand you correctly?

As I said, I haven’t tested this yet, but it should probably work.

If I simply replace the ->yaml() by ->json() and Data::encode($yamlbuilder, "yaml") by Data::encode($yamlbuilder, "json"), I get a new error:

20210106-225535_Screenshot_GoogleChrome

Adding new blocks programmatically:

$blocks   = $page->text()->toBlocks();
$newBlock = new Kirby\Cms\Block( [
  'content' => [
      'text' => kirbytext('The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. '),
  ],
  'type'     => 'text',
  'isHidden' => false,
]);

$blocks = $blocks->add($newBlock);
$kirby->impersonate('kirby');
$page->update([
  'text' => Data::encode($blocks->toArray(), 'json')
]);

What you have to add as parameters to your new Block, depends on the block type.

The alternative would be to work with $blocks->toArray() from the outset. But to me, the above seems more straightforward.