silverstripe / silverstripe-s3

Silverstripe module to store assets in S3 rather than on the local filesystem (SS4/SS5 only)
BSD 3-Clause "New" or "Revised" License
20 stars 25 forks source link

Deleting returns "PHP Warning: Trying to access array offset on value of type bool in src/Storage/AbstractCache.php on line 130" #52

Closed osynlignz closed 1 month ago

osynlignz commented 2 years ago

When deleting an image, deletion from bucket is successful and entry is deleted from SS, but request returns a 500 Error in the console and we receive the following PHP Warning in the logs:

PHP Warning: Trying to access array offset on value of type bool in .../vendor/league/flysystem-cached-adapter/src/Storage/AbstractCache.php on line 130

SilverStripe 4.10.2 silverstripe/s3 1.1.1 league/flysystem 1.1.9 PHP 8.0.8

japo32 commented 1 year ago

Happening on my setup as well.

SS 4.11.2 silverstripe/s3 1.1.1 league/flysystem 1.1.10 PHP 8.0.8

japo32 commented 1 year ago

@osynlignz I've solved it!

TLDR: when we upgraded Silverstripe psr/cache was upgraded which forced league/flysystem-cached-adapter to get downgraded which caused the break.

here's a summary:

psr/cache had been upgraded to 2.0.0 which downgraded league/flysystem-cached-adapter to 1.0.2. The latest league/flysystem-cached-adapter 1.0.9 requires psr/cache ^1.0. This was the source of the break.

So I had to manually dowgrade psr/cache to 1.0.1 so flysystem-cached-adapter can upgrade.

Also, note that flysystem-cached-adapter has version 1.1.0 but the latest silverstripe/s3 1.2.1 requires ^1.0.

Version changes in my setup:

psr/cache 2.0.0 => 1.0.1 league/flysystem-cached-adapter 1.0.2 => 1.0.9 silverstripe/s3 1.1.1 => 1.2.1

Khalsa-jio commented 1 year ago

Thanks @japo32 , It helped me to fix the issue.... I was getting this issue while publishing the image without saving it as draft.

composer require psr/cache:^1.0.1
composer require league/flysystem-cached-adapter:^1.0.9
composer require silverstripe/s3:^1.0
abdou-ghonim commented 11 months ago

It's happening on my setup as well.

SS 5 SilverStripe/s3 1.4 PHP 8.1

obj63mc commented 11 months ago

This is a bug with flysystem not a silverstripe issue.

Checkout - https://github.com/thephpleague/flysystem-cached-adapter/issues/25 https://github.com/thephpleague/flysystem-cached-adapter/issues/35 https://github.com/thephpleague/flysystem-cached-adapter/pull/37