Problem/Motivation

InboxMessageFetcher::storeMessages() sets state to unread on every message it receives. InboxMessageStorage::save() then merges on id only and writes all fields, including state.

state.

So whenever the feed returns a message that is already stored, it goes back to unread, even if the user read or dismissed it. A dismissed message shows up in the dashboard inbox again, and the unread count in the toolbar goes back up.

This started with #3546833. Before that change, the merge keys were id + state = unread, so messages that were no longer unread were never updated. Re-fetching one threw a primary key violation instead, which is what #3546833 fixed by removing the state key. The fetcher still forces unread, though, so read and dismissed messages are now silently overwritten.

Steps to reproduce

  1. Let cron fetch the inbox messages (or fetch them manually).
  2. Dismiss (or read) a message on /admin/commerce.
  3. Delete the commerce.inbox_messages_cron_last state key (drush state:del commerce.inbox_messages_cron_last) and run cron again while the message is still in the feed.
  4. The message is unread again and shows up in the inbox.

Proposed resolution

In InboxMessageFetcher::storeMessages(), keep the state of a message that is already stored, and only default to unread for new messages. The subject, body and CTA still get updated from the feed.

This also covers fetchNewStoreMessages(), which goes through the same method.

Remaining tasks

  • Fix
  • Kernel test that re-fetching a read or dismissed message keeps its state

Issue fork commerce-3635099

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jsacksick created an issue. See original summary.

jsacksick’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • jsacksick committed f69351b2 on 3.x
    fix: #3635099 Re-fetched inbox messages are reset to unread