Problem/Motivation
File entities have a field called "uid" storing the id of the owning user. The field is not marked as required and is not part of the entity keys. As a result, the Drupal API as well as the underlying database allow NULL values in the uid field.
The code in \Drupal\file\FileAccessControlHandler::checkAccess
assumes that there is always an integer. If it is null, PHP creates an E_NOTICE on the $file_uid[0]['target_id']
expression, which by default ends up in the watchdog DB table.
Steps to reproduce
Call the file APIs functions such as File::create([...])
or file_save_data(...)
from a cron or drush context.
Proposed resolution
Call getOwnerId()
instead.