Skip to content

Do not delete asset name if update request does not have a name#18470

Merged
snipe merged 1 commit intogrokability:developfrom
bilias:pr-clean
Feb 9, 2026
Merged

Do not delete asset name if update request does not have a name#18470
snipe merged 1 commit intogrokability:developfrom
bilias:pr-clean

Conversation

@bilias
Copy link
Copy Markdown
Contributor

@bilias bilias commented Jan 22, 2026

Fixes #17770 which still exists.

Upon update of an asset, if the request does not have a 'name', the old name is deleted.
Perform the same check as in checkout()

https://github.com/bilias/snipe-it/blob/2a8ebd2212de9023ec8296b929276a02b0dac9fd/app/Http/Controllers/Api/AssetsController.php#L970-L984

// Using `->has` preserves the asset name if the name parameter was not included in request.
$asset_name = request()->has('name') ? request('name') : $asset->name;

$asset->checkOut($target, auth()->user(), date('Y-m-d H:i:s'), '', 'Checked out on asset update', $asset_name, $location);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to escape that as we were before (via e()) or is it escaped elsewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have a clue.

I've copied the code from checkout() later on.
If it needs to be escaped it probably has to be escaped in both places.

Also I'm not sure what is better

request('name')
vs
$request->input('name')
vs
$request->get('name')

@snipe snipe merged commit f3cc3ed into grokability:develop Feb 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants