Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.19k stars 898 forks source link

[Bug] Laravel 10 Backpack 6 image (PRO) issue #5439

Closed MikeyBeLike closed 9 months ago

MikeyBeLike commented 10 months ago

Bug report

I'm not sure how to contribute to the new pro fields since they appear to be private now?

What I did

When using the image field there is a function getDiskUrl() , when using cloud based storage drivers like the league/flysystem-aws-s3-v3 for S3 or digital ocean the code attempts to normalise the url - by initially doing something like this:

$origin = substr(Storage::disk($disk)->url('/'), 0, -1);

this seemed like it used to work in older versions of (v1) league/flysystem-aws-s3-v3 but since laravel v9, we are required to upgrade to version 3.x of league/flysystem-aws-s3-v3

which now throws an error

InvalidArgumentException  Found 1 error while validating the input provided for the GetObject operation:
[Key] expected string length to be >= 1, but found string length of 0.

I also tested this in tinker with:

Storage::disk($cloudDisk)->url('/')

which I get the same error for.

i've solved this by creating my own function getDiskUrl() in a helpers file and instead of doing

        $origin = substr(Storage::disk($disk)->url('/'), 0, -1);
        $path = str_replace($origin, '', $path);

this seems to work fine as a replacement:

        $origin = substr(Storage::disk($disk)->url('.'), 0, -1);
        $path = str_replace($origin, '', $path);

Is it a bug in the latest version of Backpack?

yes i'm surprised no one has reported this when using other cloud disks?

After I run composer update backpack/crud the bug... is it still there?

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.2.6 (cli) (built: May 11 2023 13:02:10) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.6, Copyright (c) Zend Technologies with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies

LARAVEL VERSION:

10.41.0.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2 backpack/crud: 6.5.4 backpack/generators: v4.0.2 backpack/pagemanager: 3.2.0 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.23 backpack/revise-operation: 2.0.0 backpack/theme-coreuiv2: 1.2.2

pxpm commented 9 months ago

Hey @MikeyBeLike sorry for the time it took to answer this issue.

Somehow it slipped through the cracks and we missed it, even tho we have a script to track open/answered issues. 😞

We fixed that in PRO 2.1.3. https://backpackforlaravel.com/products/pro-for-unlimited-projects/CHANGELOG.md#2.1.3

If you update and still experiencing issues, please open a new issue and we will have a look at it.

Cheers