Link label is not updated correctly after user Subscribe/Unsubscribe

Created on 27 July 2023, over 1 year ago
Updated 6 March 2024, 9 months ago

Problem/Motivation

When a user clicks a link to subscribe to a forum taxonomy term, the label of the link is not updated correctly to display "Unsubscribe" until a page reload. And in some cases, a page reload does not even resolve the issue.

I noticed in the browser console I got an error message "User already subscribed\\/unsubscribed.". I also checked the DB and, in effect, the user was already subscribed to the forum but since the action of the link did not change to unsubscribe, the link is still pointing to the subscribe endpoint. This causes the error shown in the console.

I tried debugging the code and I noticed that the operations are cached in the Content Plugin of the Content submodule so the operations links to subscribe and unsubscribe are not updated correctly. Apparently, the change made here causes this issue https://www.drupal.org/project/danse/issues/3350871 πŸ› Huge performance issue on sites with a lot of entity types and bundles Fixed . The code that is causing the issue for me is in this function https://git.drupalcode.org/project/danse/-/commit/ea608668c414b78b2cc09565f5a1db16ccfb013c#46213d5ceb28331ceb6fbc0a9d40b66b17c95cbe_203_214.

Steps to reproduce

  1. Configure the module to display operations to subscribe to new published forum topics.
  2. Subscribe to a forum, and check if the label changes.
  3. In case the label changes, unsubscribe and subscribe again until it is not changing anymore.

Proposed resolution

Not sure if there is a way to disable this caching feature in sites with a small number of bundles.
Or an alternative is to cache only the array of the operation and calculate every time the action (Subscribe/ Unsubscribe) on the function subscriptionOperations.

πŸ› Bug report
Status

Fixed

Version

2.3

Component

Code

Created by

πŸ‡¨πŸ‡΄Colombia s_castro

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

Comments & Activities

  • Issue created by @s_castro
  • That's right, In the latest version, there's no way the user can unsubscribe after subscribing. Unless we clear the system cache. I had to revert to version 2.2.13 to fix the label.

  • πŸ‡¬πŸ‡·Greece walkero

    I am experiencing the same problem. I just started setting up this module, and it seems not to work properly because of this issue. I wonder if it is recommended to get back to the older version and if there will be an update path in the future.

  • πŸ‡ΊπŸ‡ΈUnited States rex.barkdoll

    I'm adding in as well. I'm getting a 403 Ajax error whenever trying to unsubscribe.

  • Status changed to Needs review 9 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Your observation was absolutely right @s_castro that the caching was the reason for this broken behaviour. That was introduced in πŸ› Huge performance issue on sites with a lot of entity types and bundles Fixed and increased the performance a lot. However, it cached the widget operations per entity type and entity id, but forgot about the user. These widgets are individual for each entity per user, so the user ID needs to go into the cache ID as well.

    That alone didn't fix it yet. We also need to reset the cache for an entity if the subscription status for that entity changes for a specific user.

    Both parts have been fixed and it seems to be working correctly now. Please give it a try.

  • Status changed to Active 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States rex.barkdoll

    Upgrading to the current dev version fixed my issue and seems to be working well.

  • Status changed to Fixed 9 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thanks for testing.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024