Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Image/Upload field issue with Translated attribute #5235

Closed
bedoz opened this issue Jul 26, 2023 · 2 comments
Closed

[Bug] Image/Upload field issue with Translated attribute #5235

bedoz opened this issue Jul 26, 2023 · 2 comments
Assignees
Labels
Possible Bug A bug that was reported but not confirmed yet. Priority: MUST Priority: SHOULD

Comments

@bedoz
Copy link

bedoz commented Jul 26, 2023

Bug report

What I did

I used an image field as translated field, when i edited a content and press save, it gave me:
League\Flysystem\Filesystem::delete(): Argument #1 ($location) must be of type string, null given, called in ...\vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemAdapter.php on line 518

What I've already tried to fix it

I changed vendor/backpack/crud/src/app/Library/Uploaders/Uploader.php file from:

public function getPreviousFiles(Model $entry): mixed
    {
        if (! $this->attachedToFakeField) {
            return $entry->getOriginal($this->getName());
        }

        $value = $entry->getOriginal($this->attachedToFakeField);
        $value = is_string($value) ? json_decode($value, true) : (array) $value;

        return $value[$this->getName()] ?? null;
    }

To

public function getPreviousFiles(Model $entry): mixed
    {
        if (! $this->attachedToFakeField) {
            return $entry->getAttributeValue($this->getName());
        }

        $value = $entry->getAttributeValue($this->attachedToFakeField);
        $value = is_string($value) ? json_decode($value, true) : (array) $value;

        return $value[$this->getName()] ?? null;
    }

Is it a bug in the latest version of Backpack?

Yes

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

Yes

Backpack, Laravel, PHP, DB version

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

PHP VERSION:

PHP 8.2.5 (cli) (built: Apr 12 2023 08:43:43) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies

LARAVEL VERSION:

10.16.1.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.0.2
backpack/crud: 6.0.7
backpack/filemanager: 3.0.2
backpack/generators: v4.0.2
backpack/logmanager: v5.0.0
backpack/permissionmanager: 7.0.0
backpack/pro: 2.0.9
backpack/revise-operation: 2.0.0
backpack/settings: 3.1.0
backpack/theme-coreuiv2: 1.1.4

@bedoz bedoz added the triage label Jul 26, 2023
@bedoz bedoz changed the title [Bug] [Bug] Image/Upload field issue with Translated attribute Jul 26, 2023
@pxpm pxpm self-assigned this Jul 27, 2023
@pxpm pxpm added Possible Bug A bug that was reported but not confirmed yet. and removed triage labels Jul 27, 2023
@tabacitu
Copy link
Member

Thanks Alex. Pedro is investigating this right now, he'll come back ASAP.

@pxpm
Copy link
Contributor

pxpm commented Jul 27, 2023

Hey @bedoz thanks for the report. 🙏

Indeed I can confirm that there is a bug with translatable fields and Uploads.

I've already submitted and merged the fix here: #5236

I will tag a new CRUD version with this fix later today along with some other planned fixes.

Thanks again 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Possible Bug A bug that was reported but not confirmed yet. Priority: MUST Priority: SHOULD
Projects
Status: Done
Development

No branches or pull requests

3 participants