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

Dashboard Api Controller: call UpdateComponentCommand only with modified params #4403

Open
wants to merge 1 commit into
base: 2.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions app/Http/Controllers/Dashboard/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public function postUpdateComponent(Component $component)
try {
execute(new UpdateComponentCommand(
$component,
$component->name,
$component->description,
null,
null,
Binput::get('status'),
$component->link,
$component->order,
$component->group_id,
$component->enabled,
$component->meta,
$component->tags,
null,
null,
null,
null,
null,
null,
Comment on lines +41 to +49
Copy link
Member

Choose a reason for hiding this comment

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

This definitely doesn't look right to me...

Copy link
Author

@ppomes ppomes Jun 24, 2024

Choose a reason for hiding this comment

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

Hum.. that's the same logic implemented anywhere else? Example from ./app/Bus/Handlers/Commands/Incident/CreateIncidentCommandHandler.php:

        // Update the component.
        if ($component = Component::find($command->component_id)) {
            execute(new UpdateComponentCommand(
                Component::find($command->component_id),
                null,
                null,
                $command->component_status,
                null,
                null,
                null,
                null,
                null,
                null,
                true  // Silent mode
            ));

To see the problem, try updating a component with no flag in the dashboard multiple times, and have a look to flags in DB after each update.

Pierre

Copy link
Author

Choose a reason for hiding this comment

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

To see the problem, try updating a component with no flag in the dashboard multiple times, and have a look to flags in DB after each update.

I mean: with my PR's merged last week. They broke components updates from the gui. The current PR fix them.

true // Silent mode
));
} catch (QueryException $e) {
Expand All @@ -71,15 +71,15 @@ public function postUpdateComponentOrder()

execute(new UpdateComponentCommand(
$component,
$component->name,
$component->description,
null,
null,
$component->status,
$component->link,
null,
$order + 1,
$component->group_id,
$component->enabled,
$component->meta,
$component->tags,
null,
null,
null,
null,
true // Silent mode
));
} catch (QueryException $e) {
Expand Down