getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

Query in tag field polled every 10s while page is open in panel #4740

Closed sebastiangreger closed 2 years ago

sebastiangreger commented 2 years ago

Description

Tag fields (potentially other field types as well; untested) with queries execute that query every 10 seconds while the page in question is open in the panel. With slightly more complex queries (e.g. when using ->index()) this can lead to a measurable increase in server load.

Expected behavior
The query should not be executed repeatedly.

To reproduce

  1. Install a fresh Starterkit (3.7 is fine, as this is not a new issue)
  2. Add this little plugin
// site/plugins/my-plugin/index.php
<?php
Kirby::plugin('my/plugin', [
  'pageMethods' => [
    'alltags' => function () {
      F::write(kirby()->root('logs')  . '/alltags.log', date('H:i:s'). "\r\n", true);
      return ['tag1', 'tag2', 'tag3'];
    }
  ]
]);
  1. Change the tag field in the note blueprint as follows:
# site/blueprints/pages/note.yml
tags:
  options: query
  query: page.alltags
  1. Open an existing note page in the panel
  2. Wait a minute and open file site/logs/alltags.log
  3. See how the field query got executed every 10 seconds:
    07:54:08
    07:54:18
    07:54:28
    07:54:38
    07:54:48
    07:54:58

Your setup

Fresh Starterkit 3.7.5 (also present after updating to 3.8.0-rc.1)

distantnative commented 2 years ago