Skip to content

[9.x] Storage::put() no longer throws an exception #41269

@ankurk91

Description

@ankurk91
  • Laravel Version: 9.x
  • PHP Version: Does not matter
  • Database Driver & Version: Does not matter

Description:

Storage::put() and similar methods no longer throws and and silently return false, the actual error is never logged or visible to developer

Here is responsible code

try {
if ($contents instanceof StreamInterface) {
$this->driver->writeStream($path, $contents->detach(), $options);
return true;
}
is_resource($contents)
? $this->driver->writeStream($path, $contents, $options)
: $this->driver->write($path, $contents, $options);
} catch (UnableToWriteFile $e) {
return false;
}
return true;

PR #33612

Steps To Reproduce:

Update your .env with
FILESYSTEM_DISK=s3 then make a mistake in your AWS credentials or shutdown your minio server

Try to upload a file via Storage::put("test.text","Some text");

Notice that no exception will be thrown, nothing can be found in storage/logs either.
It is impossible to get underlying adaptor error, (in my case S3)

What can be done next

Throw the exception like before (v8.x) and let end user handle it. OR
Document this change in upgrade guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions