Panel: Fetch Fields and Sections backend code executed multiple times

Hi

I might have found a bug that slows down the panel because code is executed twice or three times. Can someone confirm this behaviour or tell me if I am doing something wrong?

It is a custom section. The network console shows that the section endpoint was only fetched once. But the logfile contains “called called” after I open the panel page. The backend code seems to be executed twice.

I can reproduce this when I put this section in page blueprints but not in the site.yml. Also when extending a core section (e.g. the pages section) it shows the same behaviour.

Kirby 3.1.3

*Edit: Fields are even worse…there functions get called 3 times on my system.

*Edit 2: For sections these two fetch calls trigger the log:

  1. api/pages/mypage?view=panel
  2. api/pages/mypage/sections/testbed

Which contradicts to the sections description in the docs where it says that they are async loaded and should not block the panel…but they actually do.

# some page blueprint
title: Test
sections:
  fieldtest:
    type: fields
    fields:
      myfield:
        type: testfield
  testbed:
    type: test
// index.php
Kirby::plugin('mullema/test', [
    'fields' => [
      'testfield' => [
          'props' => [
              'moeli' => function() {
                  file_put_contents("field-logme.txt", "called ", FILE_APPEND);
                return "moeli";
              }
          ]
      ]
    ],
    'sections' => [
        'test' => [
            'computed' => [
                'something' => function(){
                    file_put_contents("logme.txt", "called ", FILE_APPEND);
                    return "something";
                }
            ]
        ]
    ]
]);
// index.js
panel.plugin('mullema/test', {
    fields: {
        testfield : {
            props: {
                moeli: String
            },
            template: `
                <div>{{ moeli }}</div>
            `
        }
    },
    sections: {
        test: {
            data: function () {
                return {
                    something: null
                }
            },

            created: function () {
                this.load().then(response => {
                    this.something = response.something;
                });
            },
            template: `
                <div>{{ something }}</div>
             `
        }
    }
});

Should be solved in 3.2