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

[v2] Partial reload incorrectly evaluates props not included in response (optional & lazy)

Open MarcEspiard opened this issue 4 months ago • 0 comments

Hi,

Testing v2 beta1 released today.

Just testing deferred props and noticed that my shared props were evaluated during the loading of the deferred props (partial load), even though all my shared props are in the Optional form and shouldn't be evaluated during a partial load.

"shared_list" => fn() => ...

I've tracked the issue to the resolveProperties function in Response: https://github.com/inertiajs/inertia-laravel/blob/141256b2ed1833158852c9d239d00abec8ff4942/src/Response.php#L134-L159

Calling https://github.com/inertiajs/inertia-laravel/blob/141256b2ed1833158852c9d239d00abec8ff4942/src/Response.php#L144 resolves all props, no matter if they are supposed to be included in the response.

Moving $props = $this->resolveArrayableProperties($props, $request); below resolveExcept solves the issue as the props have been filtered at the point.

I don't know the potential ramifications of moving this line of code since this is a brand new refactor, but if it's OK with you I'm happy to submit a PR for the fix. Just let me know

MarcEspiard avatar Oct 10 '24 23:10 MarcEspiard