Save is slow and hangs if page has an overwritten structure field

Since I’m hoping to customise the way structures are displayed in the panel, I started experimenting with custom form fields. I copied the structure field folder from panel/app/fields in to the site/fields folder to overwrite the native structure field as per the Getting Started guidance. Made my tweaks and was happy with the way they looked, all was well.

Shortly after, I realised that it was taking unusually long to save changes in the panel on pages using the structure field. The thin white progress bar along the top of the screen progresses really slowly (maybe 60 seconds?) and then stops just before it finishes so you never receive the visual confirmation that the content has saved. That said, when I reload the page the changes seem to be saved.

To reduce inconsistencies I retraced my steps, copying the native structure field files in to sites/fields and this time leaving them untouched. Tested saving again and had the same results as above.

I checked Chrome’s inspector and found these notices and warnings when the save button is clicked (site-dir being my site directory):

Notice: Undefined property: Collection::$data in /site-dir/kirby/toolkit/lib/collection.php on line 482
Warning: array_change_key_case() expects parameter 1 to be array, null given in /site-dir/kirby/toolkit/lib/collection.php on line 482
Notice:  Indirect modification of overloaded property Collection::$data has no effect in /site-dir/kirby/toolkit/lib/i.php on line 47

Those three lines above appear over and over, figure I wouldn’t repeat them so much above though!

Has anyone else out there on the forum run in to a problem like this, or do you maybe have a hunch as to what might be going wrong? I’d be very happy to raise an issue for this on GitHub but wanted to see what forum folks thought first since I am new-ish to Kirby, it’s certainly possible I’ve missed something!

To really test this, I stripped this particular page’s blueprint of all field definitions and added them back one by one. Ultimately, the problem was not the overwritten structure field but another field which I had named data. It probably was conflicting with an existing method in some way. Sorry for the convoluted-ness above! Seems I should be much careful about my field names…

Hey Piper, yea it seems that your data field has overwritten the actual $data property of the collection class which is one of the foundations for many things in Kirby. Maybe there should be a test/warning in the panel for all “dangerous” field names.

2 Likes

It’d be helpful to have a warning along those lines, but equally I imagine it might get pretty unwieldy depending upon the number of “dangerous” names! TBH I probably should have just known better than to use something like data. :blush: oh well!