spatie / flysystem-dropbox

A flysystem driver for Dropbox that uses the v2 API
https://freek.dev/734-dropbox-will-turn-off-v1-of-their-api-soon-its-time-to-update-your-php-application
MIT License
342 stars 50 forks source link

Checking for file or directory #93

Closed lianee closed 1 year ago

lianee commented 1 year ago

Hi, I was previously using flysystem 1.1.10, barryvdh/elfinder-flysystem-driver v0.3.0 and spatie/flysystem-dropbox 1.2.3, and all was well. Upgraded to bookworm, PHP8.2, flysystem 3.15.1, elfinder-flysystem-driver v0.4.3 and spatie/flysystem-dropbox 3.0.0, and every operation leads to a PHP Fatal error, because the driver gets confused when checking fileExists() for a directory and getting a true value, considering the directory is a file. That and the fact that PHP8 now triggers a fatal error for wrong return types when the driver tries to get the mime type of a directory. I think that the check for fileExists() and directoryExists() should return true only if the element is of the desired type, not only if it exists.

PHP Fatal error:  Uncaught TypeError: League\Flysystem\Filesystem::mimeType(): Return value must be of type string, null returned in /var/www/sw3/000_common/common/vendor/league/flysystem/src/Filesystem.php:150
Stack trace:
#0 /var/www/sw3/000_common/common/vendor/barryvdh/elfinder-flysystem-driver/src/Driver.php(254): League\Flysystem\Filesystem->mimeType()
freekmurze commented 1 year ago

We'll handle this in #94