Error when item is saved

We started getting the error below when saving an item. I think the item was saved after files were deleted from the item.

We only got the error for one item and only for a few minutes. I haven’t been able to replicate the problem, but I’d like to prevent it from happening again if possible.

Any ideas why we’d get this error?

[25-Jun-2019 19:23:39 UTC] PHP Warning:  Creating default object from empty value in /application/models/Item.php on line 264
[25-Jun-2019 19:23:39 UTC] PHP Fatal error:  Uncaught Error: Call to undefined method stdClass::save() in /application/models/Item.php:265
Stack trace:
#0 /application/libraries/Omeka/Record/AbstractRecord.php(280): Item->afterSave(Array)
#1 /application/libraries/Omeka/Record/AbstractRecord.php(548): Omeka_Record_AbstractRecord->runCallbacks('afterSave', Array)
#2 /application/libraries/Omeka/Controller/AbstractActionController.php(229): Omeka_Record_AbstractRecord->save(false)
#3 /application/controllers/ItemsController.php(88): Omeka_Controller_AbstractActionController->editAction()
#4 /application/libraries/Zend/Controller/Action.php(516): ItemsController->editAction()
#5 /application/libraries/Zend/Controller/Dispatcher/Standard.php(308): Zend_Co in /application/models/Item.php on line 265

Any thoughts on why this would be glitchy and not replicable?

Hmmm… this error is in an area where we’re looking up the files on an item and varying order… it seems like it could happen if files were deleted from an item in between when the save starts and finishes? Or maybe more likely, perhaps even if just the edit form was loaded, then some files were deleted by another user or in another window, and then the form was submitted?