Laravel-Backpack / CRUD

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

[Bug] CRUD Repeatable field with sub field image. Use withFiles param path broken file after update model. #5549

Open dimkys opened 5 months ago

dimkys commented 5 months ago

Bug report

What I did

I added a repeatable field with an image subfield. The image has parameters: 'withFiles' => [ 'disk' => 'public', 'path' => 'registration-steps',],

When creating everything works fine, but when updating there is a problem.

CRUD::addField([
            'name' => 'images',
            'label' => 'Images',
            'type' => 'repeatable',
            'subfields' => [
                [
                    'name' => 'image',
                    'type' => 'image',
                    'label' => 'Image',
                    'withFiles' => [
                        'disk' => 'public',
                        'path' => 'registration-steps',
                    ],
                    'wrapper' => ['class' => 'form-group col-md-4'],
                ],

            ],
            'min_rows' => 0,
            'reorder' => true,
        ]);

What I expected to happen

After creation. I change the data (associated with inages) and save. The data has changed and everything is fine. And this json data not changed "[{\"image\":\"registration-steps\\\/7AASbQ8QU8QaUR9dRJOj82rNUaKnbINpzomGCYtu.jpeg\"},{\"image\":\"registration-steps\\\/4fb9ggIdOL6FCAVA7buJQ8q4zkA2VFy8iJtnXobT.png\"}]"

What happened

Data in field images broken, file deleted from disk and in db images = "[{\"image\":\"7AASbQ8QU8QaUR9dRJOj82rNUaKnbINpzomGCYtu.jpeg\"},{\"image\":\"4fb9ggIdOL6FCAVA7buJQ8q4zkA2VFy8iJtnXobT.png\"}]".

What I've already tried to fix it

So far the fix is ​​to not use 'path' in 'withFiles'

Is it a bug in the latest version of Backpack?

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:

8.1.28

PHP EXTENSIONS:

Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, SPL, pcre, readline, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, xml, wddx, xmlreader, xmlwriter, mbstring, igbinary, openssl, sockets, Phar, curl, enchant, exif, fileinfo, ftp, gd, gettext, imagick, intl, mysqli, odbc, pdo_mysql, pdo_pgsql, pdo_sqlite, soap, sqlite3, timezonedb, xmlrpc, xsl

LARAVEL VERSION:

10.48.7.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.1 backpack/crud: 6.7.15 backpack/devtools: 2.0.3 backpack/editable-columns: 3.0.9 backpack/filemanager: 3.0.4 backpack/generators: v4.0.2 backpack/langfilemanager: 5.0.0 backpack/logmanager: v5.0.1 backpack/permissionmanager: 7.0.1 backpack/pro: 2.2.0 backpack/settings: 3.1.0 backpack/theme-tabler: 1.1.1

welcome[bot] commented 5 months ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use GitHub Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

pxpm commented 4 months ago

Hello @dimkys thanks for the report.

We are aware of some issues related with uploaders and we have already a big PR to update them. The PR is in testing phase. #5478

There is also a companion PR for that one in PRO that targets the image uploader.

We hope to merge it during this month. I will keep this issue open until we do that and let you know, so that you can update to the fixed versions.

Cheers