Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notifications #5959

Merged
merged 1 commit into from
Dec 22, 2023
Merged

Fix notifications #5959

merged 1 commit into from
Dec 22, 2023

Conversation

Alkarex
Copy link
Member

@Alkarex Alkarex commented Dec 21, 2023

The notification about wrong login was not working. Noticed while working on #5955
This was due to timing of when the notification is retrieved.
Simplified code to make the logic easier and more robust.

The notification about wrong login was not working. Noticed while working on FreshRSS#5955
This was due to timing of when the notification is retrieved.
Simplified code to make the logic easier and more robust.
@Alkarex Alkarex added the Bug (confirmed) 🐞 issues that are reproducable label Dec 21, 2023
@Alkarex Alkarex added this to the 1.23.0 milestone Dec 21, 2023
Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I haven't tested it.

$status = $this->notification['type'];

$notif = Minz_Request::getNotification();
if (!empty($notif)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!empty($notif)) {
if ($notif !== null && array_key_exists('content', $notif) && array_key_exists('type', $notif)) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is already done by type declaration (this code already passes PHPStan Level 9). And if anything, array_key_exists does not seem like the correct test as it accepts null, which we do not want.
We could consider using ?? below for providing default values, but I do not think it is necessary for now.

$msg = $this->notification['content'];
$status = $this->notification['type'];
$notif = Minz_Request::getNotification();
if (!empty($notif)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!empty($notif)) {
if ($notif !== null && array_key_exists('content', $notif) && array_key_exists('type', $notif)) {

@Alkarex Alkarex merged commit c7a3281 into FreshRSS:edge Dec 22, 2023
2 checks passed
@Alkarex Alkarex deleted the fix-notifications branch December 22, 2023 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug (confirmed) 🐞 issues that are reproducable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants