500-Internal Server error in some files

PHP 8.1.2 (tested also with 8.0)
NC 24.0.4
Apache server on Ubuntu Server 22

I’m having some 500-Internal Server Error messages in the Sync app (MacOS v 3.5.4), some files files sync ok but sometimes a few show error 500 on PUT https.

Here is the nextcloud.log of one of them:

{“reqId”:“igrKcAvrxjvk5H7xPfXu”,“level”:3,“time”:“2022-08-24T08:13:41+00:00”,“remoteAddr”:“192.168.100.20”,“user”:“xxxx”,“app”:“PHP”,“method”:“PUT”,“url”:“/remote.php/dav/files/xxxxxx”,“message”:“Opis\Closure\SerializableClosure implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) at /var/www/html/nextcloud/3rdparty/opis/closure/src/SerializableClosure.php#18”,“userAgent”:“Mozilla/5.0 (Macintosh) mirall/3.5.4git (build 11184) (Nextcloud, osx-21.6.0 ClientArchitecture: x86_64 OsArchitecture: x86_64)”,“version”:“24.0.4.1”,“exception”:{“Exception”:“Error”,“Message”:“Opis\Closure\SerializableClosure implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) at /var/www/html/nextcloud/3rdparty/opis/closure/src/SerializableClosure.php#18”,“Code”:0,“Trace”:[{“file”:“/var/www/html/nextcloud/3rdparty/opis/closure/src/SerializableClosure.php”,“line”:18,“function”:“onError”,“class”:“OC\Log\ErrorHandler”,“type”:“::”},{“file”:“/var/www/html/nextcloud/lib/composer/composer/ClassLoader.php”,“line”:571,“args”:[“/var/www/html/nextcloud/3rdparty/opis/closure/src/SerializableClosure.php”],“function”:“include”},{“file”:“/var/www/html/nextcloud/lib/composer/composer/ClassLoader.php”,“line”:428,“function”:“Composer\Autoload\includeFile”},{“file”:“/var/www/html/nextcloud/3rdparty/opis/closure/functions.php”,“line”:18,“function”:“loadClass”,“class”:“Composer\Autoload\ClassLoader”,“type”:“->”},{“file”:“/var/www/html/nextcloud/lib/private/Command/CronBus.php”,“line”:72,“function”:“Opis\Closure\serialize”},{“file”:“/var/www/html/nextcloud/lib/private/Command/CronBus.php”,“line”:45,“function”:“serializeCommand”,“class”:“OC\Command\CronBus”,“type”:“->”},{“file”:“/var/www/html/nextcloud/lib/private/Command/AsyncBus.php”,“line”:45,“function”:“queueCommand”,“class”:“OC\Command\CronBus”,“type”:“->”},{“file”:“/var/www/html/nextcloud/apps/files_versions/lib/Storage.php”,“line”:733,“function”:“push”,“class”:“OC\Command\AsyncBus”,“type”:“->”},{“file”:“/var/www/html/nextcloud/apps/files_versions/lib/Versions/LegacyVersionsBackend.php”,“line”:90,“function”:“scheduleExpire”,“class”:“OCA\Files_Versions\Storage”,“type”:“::”},{“file”:“/var/www/html/nextcloud/apps/files_versions/lib/Versions/VersionManager.php”,“line”:92,“function”:“createVersion”,“class”:“OCA\Files_Versions\Versions\LegacyVersionsBackend”,“type”:“->”},{“file”:“/var/www/html/nextcloud/apps/files_versions/lib/Storage.php”,“line”:217,“function”:“createVersion”,“class”:“OCA\Files_Versions\Versions\VersionManager”,“type”:“->”},{“file”:“/var/www/html/nextcloud/apps/files_versions/lib/Hooks.php”,“line”:56,“function”:“store”,“class”:“OCA\Files_Versions\Storage”,“type”:“::”},{“file”:“/var/www/html/nextcloud/lib/private/legacy/OC_Hook.php”,“line”:106,“function”:“write_hook”,“class”:“OCA\Files_Versions\Hooks”,“type”:“::”},{“file”:“/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/File.php”,“line”:449,“function”:“emit”,“class”:“OC_Hook”,“type”:“::”},“file”:“/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/File.php”,“line”:178,“function”:“emitPreHooks”,“class”:“OCA\DAV\Connector\Sabre\File”,“type”:“->”},{“file”:“/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php”,“line”:1137,“function”:“put”,“class”:“OCA\DAV\Connector\Sabre\File”,“type”:“->”},{“file”:“/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php”,“line”:492,“function”:“updateFile”,“class”:“Sabre\DAV\Server”,“type”:“->”,“args”:[“*** sensitive parameters replaced ***”]},{“file”:“/var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php”,“line”:89,“function”:“httpPut”,“class”:“Sabre\DAV\CorePlugin”,“type”:“->”},{“file”:“/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php”,“line”:472,“function”:“emit”,“class”:“Sabre\DAV\Server”,“type”:“->”},{“file”:“/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php”,“line”:253,“function”:“invokeMethod”,“class”:“Sabre\DAV\Server”,“type”:“->”},{“file”:“/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php”,“line”:321,“function”:“start”,“class”:“Sabre\DAV\Server”,“type”:“->”},{“file”:“/var/www/html/nextcloud/apps/dav/lib/Server.php”,“line”:358,“function”:“exec”,“cl
ass”:“Sabre\DAV\Server”,“type”:“->”},{“file”:“/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php”,“line”:35,“function”:“exec”,“class”:“OCA\DAV\Server”,“type”:“->”},{“file”:“/var/www/html/nextcloud/remote.php”,“line”:166,“args”:[“/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php”],“function”:“require_once”}],“File”:“/var/www/html/nextcloud/lib/private/Log/ErrorHandler.php”,“Line”:92,“CustomMessage”:“–”}}

Any idea about how to solve the error?