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

Throw invalid dimension exception during rendering graph with wrong height/width values #17320

Merged
merged 3 commits into from Mar 11, 2021

Conversation

flamisz
Copy link
Contributor

@flamisz flamisz commented Mar 9, 2021

Description:

fixes #17092

The package we use for rendering graphs has a bug. To avoid run into that bug, we can check the values we send to the package and if the values would cause the modulo zero error we throw an exception instead.
Our plugin throws the exceptions as an image by default, but for this error it's not that useful, because usually it happens when the height value is too small, so the user wouldn't be able to read the error message.
For this specific exception I used the default way.

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
Copy link
Member

sgiehl commented Mar 9, 2021

Wondering if it might make more sense to define lower limits for height & weight and automatically set those parameters to the lower limit if they are smaller. That way we could avoid any exception at all.

@flamisz
Copy link
Contributor Author

flamisz commented Mar 9, 2021

Wondering if it might make more sense to define lower limits for height & weight and automatically set those parameters to the lower limit if they are smaller. That way we could avoid any exception at all.

Hey @sgiehl, me and @tsteur were talking about that, and I could calculate that, but if the user wants a lower number, and the graph will be higher, maybe she/he will think it is a bug. Hard to tell which is the better solution, but probably it is something that happens very rarely.

@tsteur
Copy link
Member

tsteur commented Mar 9, 2021

@sgiehl the thought was that if we automatically change a height or width then it will look like a bug and we're getting bug reports and emails about it vs this way it's clear what the problem is and they can change the parameters to a higher number.

@sgiehl
Copy link
Member

sgiehl commented Mar 10, 2021

Thought we would have it that way in other places, but wasn't able to find one right now. But it's also fine this way.

plugins/ImageGraph/API.php Outdated Show resolved Hide resolved
@flamisz flamisz self-assigned this Mar 10, 2021
@flamisz flamisz added 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. labels Mar 10, 2021
@sgiehl sgiehl removed the Needs Review PRs that need a code review label Mar 11, 2021
@sgiehl sgiehl merged commit e3e9132 into 4.x-dev Mar 11, 2021
@sgiehl sgiehl deleted the 17092-modulo-by-zero-error branch March 11, 2021 08:02
@sgiehl sgiehl added this to the 4.3.0 milestone Mar 11, 2021
@sgiehl sgiehl mentioned this pull request Mar 11, 2021
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

fatal error: Modulo by zero: method=imageGraph while widht = 0
3 participants