Profile JSON:API POST does not invalidate cache for JSON:API GET

Created on 17 November 2023, about 1 year ago

Problem/Motivation

When someone wants to add their profile through a JSON:API POST request, it does get updated. The changes are present in the CMS. But if you do a GET request for this user, you don't see any changes.

Steps to reproduce

Use the following POST request:
POST: {your_host}/json_api/profile/{your_profile}
Body:

"data": {
      "type": "profile--{your_profile}',
      "attributes": {
        ...
      },
      "relationships": {
        ...
        "uid": {
          "data": {
            "type": "user--user",
            "id": {you_user_id},
          },
        },
      }
}

After the post request is done, do a get request for this profile to see that nothing has been added:
GET: {your_host}/json_api/profile/{your_profile}

Proposed resolution

Make sure cache gets invalidated for the specific user when a POST request is performed.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands arlanschouwstra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @arlanschouwstra
  • 🇳🇱Netherlands arlanschouwstra

    I came up with a temporary fix. If I do a $user->save(); in a hook_enity_insert() it works properly. This is probably because the profile is combined with the user, but the user does not get updated.

    Might be something to look into.

  • 🇮🇱Israel jsacksick

    Well I do believe core should be responsible for that... And it probably is clearing the necessary caches... Do you use a CDN? Perhaps you have the page cache module enabled?

Production build 0.71.5 2024