Laravel-Backpack / CRUD

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

[Bug] Image in repeatable is always deleted on update #5544

Closed eleven59 closed 3 months ago

eleven59 commented 3 months ago

Bug report

What I did

Added an image field in a repeatable field, and used withFiles for storage. The first save, the image is uploaded correctly. When updating the entry again and not changing the image, the image is deleted.

Steps to reproduce:

  1. Create new entry
  2. Add repeatable item and include image
  3. Save entry
  4. Edit entry
  5. Save entry without changing anything
  6. Edit entry -> image is now deleted

What I expected to happen

Image should not be deleted

What happened

Image was deleted anyway. It seems like the repeatable field thinks I replaced it and thus wants to delete the old image.

What I've already tried to fix it

I have now disabled the Storage::disk($this->getDisk())->delete($image); line in uploadRepeatableFiles, in vendor/Backpack/CRUD/app/Library/Uploaders/SingleBase64Image.php on line 57, but this is of course not the appropriate solution.

Is it a bug in the latest version of Backpack?

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:
8.2.20

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, FFI, fileinfo, filter, ftp, gd, gmp, json, iconv, SPL, session, standard, mbstring, igbinary, imagick, imap, intl, ldap, exif, mysqlnd, mysqli, pcntl, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, random, readline, redis, Reflection, shmop, SimpleXML, soap, sockets, sodium, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, zstd, Zend OPcache

### LARAVEL VERSION:
11.11.1.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.4
backpack/crud: 6.7.17
backpack/generators: v4.0.5
backpack/pro: 2.2.4
backpack/settings: 3.1.1
backpack/theme-tabler: 1.2.10