Hi, I’m trying to add a unique id to a structure field after the page is saved. However, it keeps throwing the following error in a modal after saving:
The JSON Preformatted text response from the API could not be parsed. Please check your API connection.
The id field is a basic text field and not disabled. There’s nothing else happening with hooks and if I disable the hook, the page saves without any errors. I just updated Kirby to 3.0.2.
What else could interfere?
Here’s the structure field:
locations:
label: Locations
type: structure
sortBy: en
translate: false
fields:
en:
label: EN
type: text
required: true
nl:
label: NL
type: text
required: true
id:
type: text
I’ve tried to save the page with batches of the content present in the content file +/-10% each time to find an item/character that causes the error. No errors, for none of the content. But when all the content is present, it throws the error. Could it be a timeout, there’s a lot of content and saving takes quite a while.
Browsing through the network tab → response while using ->update() I can see that php returns Fatal error: Maximum execution time.... which is causing the JSON error. ->save() is probably faster and not causing the fatal error.
Interesting, but I thought that the hook was not triggered again from a $page->update()within a hook. If that was the case, wouldn’t the same hook with less entries run into the same issue, @lukaskleinschmidt? Trying to understand…
If I understand Bastians answer in the issue posted above correctly, it is not an infinite loop with the update hook calling itself but somewhere in the validation process.
Would be interesting to know what causes it…a lot of text? a lot of items?
I am wondering why the page is so slow in general. It takes about 12 seconds to load the page. The page tab consists only of a few structure fields with +/- 150 items in total. The page on the front-end does load fast without caching.