8000 PATCH request has stale model relationship data · Issue #223 · laravel-json-api/laravel · GitHub
[go: up one dir, main page]

Skip to content
PATCH request has stale model relationship data #223
Closed
@asugai

Description

@asugai

Per discussions with @lindyhopchris on Slack:

on a PATCH request, this package serializes the model to its JSON:API representation before validation occurs, so that we can give the validator the current values of anything that hasn't been sent in the request.

This causes the model to cache the relationship in it's pre-patched state so when the model then later gets serialized for the response, it's got stale data in its relationship cache.

The only fix, is to $model->refresh() in the updated hook on the controller.

If possible, we need to always refresh the model to be sure that the package has non-stale data.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0