File uploaded not hashing

Created on 26 July 2023, over 1 year ago
Updated 29 August 2023, about 1 year ago

Problem/Motivation

Warning: hash_file(public://2023-01/1323d89e32887e58b5b64a8bf99b0410.png): Failed to open stream: "Drupal\Core\StreamWrapper\PublicStream::stream_open" call failed in Drupal\filehash\FileHash->hash() (line 257 of /opt/drupal/docroot/modules/contrib/filehash/src/FileHash.php)

Steps to reproduce

Upload image via media

πŸ› Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @yellowpomelo
  • Issue was unassigned.
  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    I'm not able to reproduce this bug. Are you able to reproduce it on a fresh install of drupal, or is some other contrib or custom module required? Any specific configuration necessary to reproduce it?

    Please either update the issue summary with clearer steps to reproduce, or write a failing test that I could use to reproduce the issue.

  • πŸ‡ͺπŸ‡¨Ecuador afsch Otavalo

    I'm gettings the same message, this is running a Behat test to delete a file, in some scenarios, it already exists but in others, it doesn't, the purpose is to make sure that before the tests run the file doesn't exist.

    Given I delete a ABC video with ABC manager ID "2cbb517a-2f0c-4ddc-a113-73ea94bee253" if any 
    # tests/features/media/pbs_video/crud.feature:27
            Warning: hash_file(public://gpb_remote_media_thumbnails/WdrbXZ_AzM_3MIlpYUcrnp-SeYxR26zZUWDTw0FS_mU.png): Failed to open stream: "Drupal\Core\StreamWrapper\PublicStream::stream_open" call failed in docroot/modules/contrib/filehash/src/FileHash.php line 257 (Drupal\Core\Entity\EntityStorageException)
    

    I could not fix it locally, but I'm guessing the origin of the issue is a missing validation when a file doesn't exist.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    Filehash module intentionally allows the PHP warning to be logged when a nonexistant or unreadable file is hashed. In fact, we have a test that ensures this PHP warning is logged.

    So, if you write a test that involves filehash hashing a nonexistent file then it should also expect a PHP warning.

    I am thinking perhaps Filehash module should log its own warning in this case rather than relying on the PHP warning?

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    A complicating factor here is that there are some remote files, e.g. HTTP URLs, that can be hashed, but we cannot actually determine whether or not the file exists, or is readable. So, I'm not sure what the best solution is here, but the easiest solution, for me, is to simply rely on the PHP warnings.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    As far as non-existent files go, it seems best to treat this as a duplicate of ✨ Allow disabling of automatic hash generation when files are loaded Fixed - sites probably won't run into this warning if they disable automatic hashing when loading files.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    I also filed a feature request to allow the warnings to be suppressed: ✨ Allow warnings re: nonexistent/unreadable files to be suppressed Fixed

  • Status changed to Closed: cannot reproduce about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    I could not reproduce the issue reported by @yellowpomelo - and it's been a month - so I'll close this for now but feel free to re-open if you have more info

Production build 0.71.5 2024