Skip to content

Internal admin notifications are always stored #31939

Open
@kanduvisla

Description

@kanduvisla

The current way of how admin notifications are processed completely ignores if a message is internal or not. See the following code snippet that is used in Magento\AdminNotification\Model\Inbox::add():

    $this->parse(
        [
            [
                'severity' => $severity,
                'date_added' => $date,
                'title' => $title,
                'description' => $description,
                'url' => $url,
                'internal' => $isInternal,
            ],
        ]
    );

The above snippets sets internal to true or false (according to $isInternal). However, if you look at the implementation later on on how it's used:

    if (isset($item['internal'])) {
        $row = false;
        unset($item['internal']);
    } else {
        $row = $connection->fetchRow($select);
    }

    if (!$row) {
        $connection->insert($this->getMainTable(), $item);
    }

It simply checks if the property internal exists in the array $item, not if it's true or false. The result is that the admin notifications gets always persisted in the database, because the fetchRow() is never called.

The result is that a new row is always added, even if a row with identical data already exists.

Preconditions

  1. Magento 2.4-develop

Steps to reproduce

  1. Create an admin notification with the $isInternal-argument to false.
  2. Create another one

Expected result

Since the messages are identical, only one admin notification should be stored.

Actual result

2 identical notifications are stored


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: AdminNotificationIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: ready for confirmationPriority: P3May be fixed according to the position in the backlog.Progress: PR in progressReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions