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

fix(4752): Can't set server description to empty from client UI #4788

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

robertnisipeanu
Copy link
Contributor

Fixes #4752

Issue is that the middleware ConvertEmptyStringsToNull is enabled by default by Laravel.

Request:
image
Values:
image

New behavior after fix:
If description is not included in the request it will keep the old value.
If description is included but has a value of null or empty string it gets converted to null by the middleware, and then casted to empty string using a (string) cast.
If description is included and not empty, it will save that value.

Copy link

@Mubeen142 Mubeen142 left a comment

Choose a reason for hiding this comment

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

The suggested code can be simplified by doing

$request->input('description', $server->description);

Instead of

$request->has('description') ? (string) $request->input('description') : $server->description

@Boy132
Copy link
Contributor

Boy132 commented Jun 22, 2023

The suggested code can be simplified by doing

$request->input('description', $server->description);

Instead of

$request->has('description') ? (string) $request->input('description') : $server->description

No. With $request->input('description', $server->description); you still can't set the description to empty. robertnisipeanu's fix works fine.

@matthewpi matthewpi linked an issue Jul 12, 2023 that may be closed by this pull request
3 tasks
@matthewpi matthewpi merged commit 5cd2697 into pterodactyl:1.0-develop Aug 23, 2023
7 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.

Can't remove server description
4 participants