Description
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
- Magento 2.4-develop
Steps to reproduce
- Create an admin notification with the
$isInternal
-argument tofalse
. - 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”.