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

[4.x]: Restore button is missing from Asset index #11761

Closed
Mosnar opened this issue Aug 11, 2022 · 4 comments
Closed

[4.x]: Restore button is missing from Asset index #11761

Mosnar opened this issue Aug 11, 2022 · 4 comments

Comments

@Mosnar
Copy link
Contributor

Mosnar commented Aug 11, 2022

What happened?

Description

The asset restore button is not present on the asset element index - only the Permanently Delete button is shown. This is true regardless of whether the original file was kept or discarded.

Steps to reproduce

N/A

Expected behavior

N/A

Actual behavior

N/A

Craft CMS version

4.2.1.1 Pro

PHP version

8.0

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

N/A

@brandonkelly
Copy link
Member

This is true regardless of whether the original file was kept or discarded.

There’s no option to keep the files when deleting assets, though. Which is why there’s no “Restore” button – there’s never going to be a file to restore.

@Mosnar
Copy link
Contributor Author

Mosnar commented Aug 11, 2022

This is true regardless of whether the original file was kept or discarded.

There’s no option to keep the files when deleting assets, though. Which is why there’s no “Restore” button – there’s never going to be a file to restore.

@brandonkelly there is if you use it programmatically:

cms/src/elements/Asset.php

Lines 699 to 704 in c659d09

/**
* @var bool Whether the associated file should be preserved if the asset record is deleted.
* @see beforeDelete()
* @see afterDelete()
*/
public bool $keepFileOnDelete = false;

For context, I was looking at making adjustments to the S3 plugin to make use of S3's version history, which allows files to be marked as deleted without permanently deleting them, thus allowing me to implement a "restore" function.

@brandonkelly
Copy link
Member

Ah good point.

@brandonkelly brandonkelly reopened this Aug 16, 2022
brandonkelly added a commit that referenced this issue Aug 16, 2022
@brandonkelly
Copy link
Member

Made it possible to restore soft-deleted assets in Craft 4.3, provided they were programmatically deleted with $keepFile == true.

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

No branches or pull requests

2 participants