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 possible notice when no user is set #17624

Merged
merged 1 commit into from May 27, 2021
Merged

Fix possible notice when no user is set #17624

merged 1 commit into from May 27, 2021

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented May 26, 2021

Description:

Especially in tests it might be possible that a user is actually not set. If for any reason Piwik::getCurrentUserEmail() is then called a notice might be triggered causing a test to fail.

In theory there might also be other use cases where that could happen. Like using a custom login plugin, that actually does not use the users stored in database.

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@sgiehl sgiehl added c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. Needs Review PRs that need a code review labels May 26, 2021
@sgiehl sgiehl added this to the 4.4.0 milestone May 26, 2021
@@ -176,7 +176,7 @@ public static function getRandomTitle()
public static function getCurrentUserEmail()
{
$user = APIUsersManager::getInstance()->getUser(Piwik::getCurrentUserLogin());
return $user['email'];
Copy link
Member

Choose a reason for hiding this comment

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

I think the phpdocs need to be changed here too. And do we need to mention in the developer changelog that the value can be empty now? I guess it might always have been possible if the user was anonymous...

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 phpdocs now actually would fit. Before it could maybe have returned null if the user array was empty.
Don't think we need to mention it in the developer docs. The change actually only avoids a possible warning in this case.

@diosmosis diosmosis merged commit f4519d1 into 4.x-dev May 27, 2021
@diosmosis diosmosis deleted the fixnotice branch May 27, 2021 16:34
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Tests & QA For issues related to automated tests or making it easier to QA & test issues. Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants