Marking notifications read does not work

Created on 14 February 2023, almost 2 years ago
Updated 2 May 2023, over 1 year ago

Problem/Motivation

I wonder if I am the first one among the maintainers of those 400+ websites reporting the use of this module who noticed that the โ€œClear Allโ€ link of the notification widget does not work neither since versions 1.6, 1.8, nor in the latest version 2.x-dev.

<!--break-->

To get into the technical details: clicking on the link invokes the URL path /api/notification_update?_format=json with the following payload (example values):

{
  "notification_action": "clearall",
  "notiId": "73",
  "uid": "1"
}

This /api/notification_update path is defined by the notifications_update_widget plugin which also handles its data exchange in its
Drupal\notifications_widget\Plugin\rest\resource\NotificationWidgetUpdateResource::post() method. After it has decoded the received payload, sets the parsed values onto local variables.

$action = $notificationData['notification_action'];
$id = (is_numeric($notificationData['nasId'])) ? $notificationData['nasId'] : NULL;
$notificationId = $notificationData['notiId'];

The problem is that there's no array item with the key โ€œnasIdโ€. (Which string sounds a bit gibberish to me making it hard to track back what it was supposed to mean originally.) Out of curiosity I just replaced it with โ€œuidโ€ and voilรก! โ€“ then marking notifications read works again. (Maybe worth to note that using โ€œnotiIdโ€ for the same purpose also resolves the problem.)

Steps to reproduce

  1. Click on the โ€œClear Allโ€ link when current user at least one unread notification.
  2. Check the wbe browser's console as request is being sent but returns a non-2xx status code.

Proposed resolution

Fix the array key name to an existing one.

Remaining tasks

Discuss, review, merge, release, profit.

User interface changes

No visual difference but restoring a regressional bug.

API changes

N. a.

Data model changes

N. a.

๐Ÿ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

๐Ÿ‡ญ๐Ÿ‡บHungary Balu Ertl Budapest ๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024