Skip to content

[Bug] uploader: overwrite field when update model #5711

@tjslash

Description

@tjslash

Bug report

What I did

CRUD article controller with field:

CRUD::addField([
    'name' => 'image',
    'label' => 'Image',
    'type' => 'image',
    'withFiles' => [
        'disk' => 'public',
        'path' => 'storage/images'
    ],
    'tab' => 'Images'
]);

and a FrontController file:

$article = Article::ofSlug($request->route('article'))->firstOrFail();
$article->update([
    'views' => $article->views + 1
]);
  1. Open admin page a CRUD article
  2. Upload image file and save article
  3. Open web page a FrontController

What I expected to happen

The count of views should be increase.

What happened

Views has been increase successful. But each 16th request: image set is NULL;

Query log:

update `articles` set `image` = NULL, `views` = 29, `articles`.`updated_at` = "2024-11-01 00:59:52" where `id` = 1;

Is it a bug in the latest version of Backpack?

Yes.

Backpack, Laravel, PHP, DB version

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

### PHP VERSION:
8.3.4

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, ctype, curl, dom, fileinfo, filter, hash, iconv, json, mbstring, SPL, session, PDO, pdo_sqlite, standard, posix, random, readline, Reflection, Phar, SimpleXML, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, bcmath, exif, gd, intl, mysqli, pcntl, pdo_mysql, redis, soap, sockets, sodium, zip, Zend OPcache, xdebug

### LARAVEL VERSION:
11.28.1.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.6
backpack/crud: 6.7.41
backpack/generators: v4.0.5
backpack/logmanager: v5.0.1
backpack/permissionmanager: 7.2.0
backpack/pro: 2.2.21
backpack/settings: 3.1.1
backpack/theme-coreuiv2: 1.2.3
backpack/theme-coreuiv4: 1.1.1

Octane with RoadRunner:

laravel/octane : 2.3.7
spiral/roadrunner: 2023.3.12
spiral/roadrunner-http: 3.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions