Drupal 9.3
We have a site that allows private file uploads. We get intermittent files that cannot be viewed/downloaded, even with the "User 1" account.
There is no difference between a denied file and other files that can be viewed. The file exists in the Drupal Files Views and is used in 1 place as expected. The file exists on the server and has the same UNIX permissions.
Troubleshooting shows the Access Denied error coming from the download function in:
/web/core/modules/system/src/FileDownloadController.php
It appears that a header is getting set to -1 somewhere so I tried using hook_file_download() in a custom module with its weight set to 100 so it should fire last.
What’s baffling me is that my hook is ran last by weight and the "-1" is not in the $headers but when FileDownloadController’s download function checks it it is there.
The screenshot show dpm($headers) from my hook_download_file() that runs first and then the core download function. Where is the -1 being inserted and why is it intermittent?