statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.71k stars 508 forks source link

Deleting assets in subfolders via CP doesn't delete the corresponding .meta yaml files. #7042

Closed helloDanuk closed 8 months ago

helloDanuk commented 1 year ago

Bug description

Deleting assets in your local assets container via CP won't delete the corresponding .meta yaml files if the assets are stored in subfolders. Only .meta files form assets in your root will be deleted. Take a look at this example with one subfolder and two images.

before deleting:

before deleting

after deleting

after deleting

The meta yaml from the asset in the subfolder gets some changes though. It's no difference if you delete the asset with or without an alt-text set. Without alt text you just would have the line data: { } left after deleting.

Bildschirmfoto 2022-11-12 um 17 35 00

How to reproduce

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 9.39.0
PHP Version: 8.1.11
Composer Version: 2.4.3
Environment: local
Debug Mode: ENABLED
URL: delete.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: regex
Version: 3.3.54 Solo

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

No response

marcorieser commented 11 months ago

I can confirm that this issue still exists and is not only related to the control panel. Calling \Statamic\Assets\Asset->delete('file/in/a/subdirectory/.meta/filename.yaml') does not delete the file either. Running unlink('file/in/a/subdirectory/.meta/filename.yaml') in eg. Tinkerwell deletes it immediately. Only tested on my local Mac atm.

Here is my setup:

Environment
Application Name: MAN | CTS
Laravel Version: 10.28.0
PHP Version: 8.2.11
Composer Version: 2.6.5
Environment: local
Debug Mode: ENABLED
URL: statamic-man-cts.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Livewire
Livewire: v3.0.8

Statamic
Addons: 2
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.28.0 PRO

Statamic Addons
jonassiewertsen/statamic-livewire: 3.0.0
marcorieser/statamic-vitals: 1.1.0
jasonvarga commented 11 months ago

It looks like the file does actually get deleted, but immediately re-created.

Seems to be in Asset@resolvePendingMetaOriginalValues() when getOriginal() is called inside UpdateAssetReferences.