cms icon indicating copy to clipboard operation
cms copied to clipboard

Error when saving entry after updating an asset's file name

Open jlmmns opened this issue 2 years ago • 1 comments

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

  1. Add an Asset field to one of your entries
  2. Select an asset and save the entry
  3. Click the "pencil" edit button on the selected asset
  4. Click button "Rename File" and change the file name
  5. 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_

jlmmns avatar Aug 03 '22 10:08 jlmmns

Thanks for the clear instructions - I can reproduce!

duncanmcclean avatar Aug 05 '22 06:08 duncanmcclean

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!

duncanmcclean avatar Nov 20 '23 22:11 duncanmcclean