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] Uploaded files cannot be deleted #5411

Closed
misiekch opened this issue Dec 26, 2023 · 2 comments
Closed

[Bug] Uploaded files cannot be deleted #5411

misiekch opened this issue Dec 26, 2023 · 2 comments

Comments

@misiekch
Copy link
Contributor

Bug report

What I did

I am using upload_multiple field with default MultipleFiles uploader.

What I expected to happen

I wanted to delete uploaded files.

What happened

Files were not deleted.

What I've already tried to fix it

3 weeks ago (on Dec 8) @pxpm committed changes to MultipleFiles.

According to fix uploaders in repeatable relationships

Line
$filesToDelete = CRUD::getRequest()->get('clear_'.$this->getName());
was replaced with
$filesToDelete = collect(CRUD::getRequest()->get('clear_'.$this->getRepeatableContainerName() ?? $this->getName()))->flatten()->toArray();

The problem is that 'clear_'.$this->getRepeatableContainerName() ?? $this->getName() returns clear_ when $this->getRepeatableContainerName() returns null.

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:

PHP 8.2.9 (cli) (built: Aug 16 2023 13:30:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.9, Copyright (c) Zend Technologies
with Zend OPcache v8.2.9, Copyright (c), by Zend Technologies

LARAVEL VERSION:

10.37.3.0

BACKPACK PACKAGE VERSIONS:

backpack/activity-log: 2.0.1
backpack/basset: 1.2.2
backpack/crud: 6.4.2
backpack/generators: v4.0.2
backpack/permissionmanager: 7.1.1
backpack/pro: 2.0.20
backpack/settings: 3.1.0
backpack/theme-tabler: 1.1.2

@karandatwani92
Copy link
Contributor

Hey @misiekch sorry for the trouble.

Hey @pxpm
I did the following to test and can confirm the delete has stopped working:
GIF ѻ
GIF

CRUD::column([
    'name'      => 'photos',
    'label'     => 'Photos',
    'type'      => 'upload_multiple',
    'withFiles' => true
]);
protected function setupDeleteOperation()
{
   CRUD::field('photos')->type('upload')->withFiles();
}

@pxpm
Copy link
Contributor

pxpm commented Dec 30, 2023

Hey @misiekch thanks for the report 🙏

Thank you also @karandatwani92 for the test and heads up 🙏

I've fixed this in 6.5.1, please let me know if you guys are still experiencing issues.

Cheers and happy new year 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants