kirby
kirby copied to clipboard
Form Class is loading queries (too?) eagerly causing (unnecessary) performance bottleneck
Describe the bug
Form class loads data even if it may be never used. it dataset is very big this causes a hugh delay for on each request. This is a common scenario in both autoid and boost plugin and currently make adding pages beyond 20k index impossible within 30sec timeout.
https://github.com/getkirby/kirby/blob/efe24a6ef4ad61010428b1cb725f8f97a633ff82/src/Cms/PageActions.php#L459
To Reproduce
-
create a lot of pages of template
human
-
create a collection that does return a site->index()
<?php
return function () {
return site()->index()->filterBy('template', 'human');
};
- create a page blueprint with a field with a multiselect query
# other fields
human:
type: multiselect
options: query
max: 1
query:
fetch: kirby.collection('humans') # this does a site index -> filter
text: "{{ page.title }}"
value: "{{ page.id }}"
- create a single or a batch of new
human
page programmatically. - the query will be executed in php code even it is most likely only used in api/kql/panel.
Expected behavior
the query should only be executed in context of api/kql/panel or when called explicitly in php.
Kirby Version
3.5.7 and 3.6.0-beta.1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
dear bot. this issue has not been resolved. please keep it open.
I think we should revisit what you wrote in "expected behavior": If we can find a way to resolve the options less often and only when they are needed, this will increase performance by a lot, no matter if a cache is used or not.
We have started refactoring our blueprint and form classes. Would be best to tackle this, once that's done.