Embedded graphs in reports render with raw metrics.#24442
Open
nathangavin wants to merge 2 commits into5.x-devfrom
Open
Embedded graphs in reports render with raw metrics.#24442nathangavin wants to merge 2 commits into5.x-devfrom
nathangavin wants to merge 2 commits into5.x-devfrom
Conversation
chippison
reviewed
Apr 30, 2026
Contributor
chippison
left a comment
There was a problem hiding this comment.
A few simplfications and everythings all good!
👍
Comment on lines
+615
to
+619
| if ($ordinateValue === null || $ordinateValue === '' || $ordinateValue === '.') { | ||
| return 0.0; | ||
| } | ||
|
|
||
| return is_numeric($ordinateValue) ? (float) $ordinateValue : 0.0; |
Contributor
There was a problem hiding this comment.
This can be replaced by:
After the preg_replace, the value can only be digits and dots, is_numeric does not add any value anymore. The function empty() also covers null and empty string
Suggested change
| if ($ordinateValue === null || $ordinateValue === '' || $ordinateValue === '.') { | |
| return 0.0; | |
| } | |
| return is_numeric($ordinateValue) ? (float) $ordinateValue : 0.0; | |
| if (empty($ordinateValue) || $ordinateValue === '.') { | |
| return 0.0; | |
| } | |
| return (float) $ordinateValue; |
Contributor
Author
There was a problem hiding this comment.
yep agreed, makes sense.
Comment on lines
+597
to
+601
| if (is_int($ordinateValue) || is_float($ordinateValue)) { | ||
| return (float) $ordinateValue; | ||
| } | ||
|
|
||
| $ordinateValue = @str_replace(',', '.', (string) $ordinateValue); |
Contributor
There was a problem hiding this comment.
Can be simplified a bit more by:
is_numeric will cover both is_int and is_float
no need to add @ as you have force $ordinateValue to be a string
Suggested change
| if (is_int($ordinateValue) || is_float($ordinateValue)) { | |
| return (float) $ordinateValue; | |
| } | |
| $ordinateValue = @str_replace(',', '.', (string) $ordinateValue); | |
| if (is_numeric($ordinateValue)) { | |
| return (float) $ordinateValue; | |
| } | |
| $ordinateValue = str_replace(',', '.', (string) $ordinateValue); |
Contributor
Author
There was a problem hiding this comment.
same here, good suggestion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Addresses #24273
When generating a report with embedded graphs in a language that uses different delimiters with numbers (e.g. '1.2' becomes '1,2'), the ImageGraph API was fetching metrics in the translated form, and using them to create the graphs to embed. Older PHP versions would implicitly handle these metrics (on PHP 7.2, '1,2' would be intepreted as 1), however newer PHP versions will hard fail on the
ceil()method when passed a string.This fix addresses this by first requesting raw metrics when generating the graph. This means that metrics should always be formatted in the standard style, which is intepreted by PHP type casting more consistently. Secondly, the method for processing ordinance values for the ImageGraph API has been hardened to always return a Float, which is what the graph generation code is expecting.
Since the raw metrics are only used to generate the graph shape (bar size, line shape etc), the end user should not be able to see any difference.
Checklist
Review