laravel / nova-issues

556 stars 34 forks source link

Incorrect method call for Batch Action in "toQueryWithoutScopes" method #6421

Closed dzandrey closed 5 months ago

dzandrey commented 5 months ago

Description:

In Laravel Nova when attempting to retrieve selected resource IDs through the selectedResourceIds() method, an issue with incorrect processing of the comma-separated string of identifiers has been discovered.

Detailed steps to reproduce the issue on a fresh Nova installation:

Open resource index page and apply any Action to multiple records

crynobone commented 5 months ago

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

crynobone commented 5 months ago

For context, Nova would only send a string as all or an array of IDs, so comma separated string is not an expectwd behaviour. This has been tested vja our integration and dusk tests. You need to submit reproduing code to confirm such issue exist.

dzandrey commented 5 months ago

@crynobone https://github.com/dzandrey/nova-issue-batch-action

crynobone commented 5 months ago

The usage of selectedResourceIds() is limited to Action Modal confirmation and not during submission and therefore isn't a bug. You should look at toSelectedResourceQuery() on how to access it, since all methods here are internal we not making changes to the above method.

dzandrey commented 5 months ago

Here is the method you're referring to. 04-2024-06-12_17-18 But it uses toQueryWithoutScopes() from which it takes $resource::detailQuery instead of $resource::indexQuery. In this case, $resource::indexQuery should be triggered because I am calling the action on the list and not on the detail page.