inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

[2.x] Ensure closures are resolved via App in resolveArrayableProperties

Open jaspertey opened this issue 1 year ago • 2 comments

This PR resolves a regression in 2.x where shared data closures with arguments could not be resolved. This patch ensures that the closures are resolved using App::call().

e.g.,

Inertia::share('query', fn (Request $request) => $request->query());

I encountered this while trying to upgrade a project to Inertia 2.x. A supporting test has been created to demonstrate further.

jaspertey avatar Oct 24 '24 17:10 jaspertey

This resolves an issue with the gretel breadcrumbs package, could this be merged? @reinink

gainlinejono avatar Oct 29 '24 09:10 gainlinejono

This resolves an issue with the gretel breadcrumbs package, could this be merged? @reinink

This was my exact use case as well, good to know I wasn't the only one.

jaspertey avatar Oct 29 '24 13:10 jaspertey

The problem is that - that closure call should not happen here as it is already happenning in the "resolvePropertyInstances" method, and there it works properly. This bug was added in the following commit: https://github.com/inertiajs/inertia-laravel/commit/141256b2ed1833158852c9d239d00abec8ff4942 and the change for the Response.php file should be reverted I think it was a left-over from some tests

wizzymore avatar Nov 12 '24 17:11 wizzymore

I see that v2.0.0 was released, and the changes in this PR were manually applied in https://github.com/inertiajs/inertia-laravel/commit/75410d7487b3ce9e11d3bddc81f0f7e7c398990e - so I will close this PR as it is officially part of 2.x and no longer relevant!

jaspertey avatar Dec 13 '24 17:12 jaspertey

@JasperTey hey, thanks anyway! 🙏

reinink avatar Dec 13 '24 17:12 reinink