cms
cms copied to clipboard
Error when saving entry after updating an asset's file name
Bug description
Saving an entry after updating one of its asset's file name, causes the following error:
Call to a member function path() on null
Both the entry and asset do get updated correctly in the filesystem, and are being displayed on the site without any problem.
After 10 minutes of inspection, it seems this error is being caused by the front-end state not being updated with the asset's new file name.
The previous file name is still present in data -> values -> {asset_field}
in the Vue component EntryPublishForm
.
How to reproduce
- Add an Asset field to one of your entries
- Select an asset and save the entry
- Click the "pencil" edit button on the selected asset
- Click button "Rename File" and change the file name
- Save the entry
Logs
{
"message": "Call to a member function path() on null",
"exception": "Error",
"file": "/.../vendor/statamic/cms/src/Fieldtypes/Assets/Assets.php",
"line": 113,
"trace": [
{
"function": "Statamic\\Fieldtypes\\Assets\\{closure}",
"class": "Statamic\\Fieldtypes\\Assets\\Assets",
"type": "->"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Collections/Arr.php",
"line": 560,
"function": "array_map"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Collections/Collection.php",
"line": 723,
"function": "map",
"class": "Illuminate\\Support\\Arr",
"type": "::"
},
{
"file": "/.../vendor/statamic/cms/src/Fieldtypes/Assets/Assets.php",
"line": 114,
"function": "map",
"class": "Illuminate\\Support\\Collection",
"type": "->"
},
{
"file": "/.../vendor/statamic/cms/src/Fields/Field.php",
"line": 300,
"function": "process",
"class": "Statamic\\Fieldtypes\\Assets\\Assets",
"type": "->"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php",
"line": 60,
"function": "process",
"class": "Statamic\\Fields\\Field",
"type": "->"
},
{
"function": "Illuminate\\Support\\{closure}",
"class": "Illuminate\\Support\\HigherOrderCollectionProxy",
"type": "->"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Collections/Arr.php",
"line": 560,
"function": "array_map"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Collections/Collection.php",
"line": 723,
"function": "map",
"class": "Illuminate\\Support\\Arr",
"type": "::"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php",
"line": 61,
"function": "map",
"class": "Illuminate\\Support\\Collection",
"type": "->"
},
{
"file": "/.../vendor/statamic/cms/src/Fields/Fields.php",
"line": 173,
"function": "__call",
"class": "Illuminate\\Support\\HigherOrderCollectionProxy",
"type": "->"
},
{
"file": "/.../vendor/statamic/cms/src/Http/Controllers/CP/Collections/EntriesController.php",
"line": 192,
"function": "process",
"class": "Statamic\\Fields\\Fields",
"type": "->"
},
{
"file": "/.../vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
"line": 54,
"function": "update",
"class": "Statamic\\Http\\Controllers\\CP\\Collections\\EntriesController",
"type": "->"
},
...
]
}
Environment
Statamic 3.3.24 Pro
Laravel 9.20.0
PHP 8.1.7
No addons installed
### Installation
Fresh statamic/statamic site via CLI
### Antlers Parser
runtime (new)
### Additional details
_No response_
Thanks for the clear instructions - I can reproduce!
Hey 👋
I'm unable to reproduce this issue on the latest version of Statamic. When I rename an asset (either in Grid or List mode), I'm able to save the entry without any errors.
I'm going to close this issue now. If you're still experiencing this issue, please leave a comment and we can re-open the issue. Thanks!