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
EmonCMS - 9.8.10 | 2017.08.17 #694
Conversation
Input null values fix.
Not sure how I missed it but: return ($lastvalue ? (float)$lastvalue : null); changes inputs and feed values that are 0 to NULL in the input and feeds list.. |
Could we also use if (condition) { } else { } notation, I find the ($lastvalue ? (float)$lastvalue : null); less clear to read.. |
How about this as an alternative?
|
You're absolutely right, see my refactor. |
Hello @chaveiro , Is this pull request needed now? Your changes revert my changes? I see there are some other changes to, would it be good to separate this out? |
Your changes on feed_model? They here refactored a check for === null is also needed. |
I dont quite understand why your replacing:
with:
your removing both my is_numeric check and is_nan check..? |
The last value can be unset when redis is flushed and the check for false
ensures we catch the null.
By casting to int i ensure to return 0 if it was not a numeric for any
other reason.
…On Aug 6, 2017 08:20, "Trystan Lea" ***@***.***> wrote:
I dont quite understand why your replacing:
if (!is_numeric($lastvalue["time"])) $lastvalue["time"] = null;
if (is_nan($lastvalue["time"])) $lastvalue["time"] = null;
with:
if (!isset($lastvalue['time']) || $lastvalue['time'] === false) {
$lastvalue['time'] = null;
} else {
$lastvalue['time'] = (int) $lastvalue['time'];
}
your removing both my is_numeric check and is_nan check..?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#694 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEUUH4fMcv1zXnvJKnDvH_0LthhfBH33ks5sVWlGgaJpZM4OdbYF>
.
|
I've created a test script to try and have a consistent way of testing this and unfortunately (float) does not convert NAN to 0. My proposed solution does catch this case. You could alternatively add the following check to fix?:
Test code
|
I've been testing with http://phptester.net/, on php 7.0 it's fine but on earlier versions the NaN is converted to -9223372036854775808? |
- is_nan checks for last value - schedule inexistant check
Some fixes on last commit |
Hello @chaveiro I tested your changes this morning, with the following test code:
Im getting the following error, sorry!: php test_decode.php |
Ops, It should be better now... Test code:
|
Unfortunatly
still fails for me. Is there any reason why we should not use my suggestion:
or my proposed modification of your suggestion?
|
both of which work fine! although there is a slight difference in output: my initial suggestion converts NAN and "string" to null, while yours with my modification converts NAN to null and "string" to 0 |
I see, different versions of php get different results... |
Great it passes! :) I will merge this. Is there any risk in removing the float casting in input_model set_timevalue? |
You're referring to this line ? The $stmt->bind_param casts already (to double). |
Thanks @chaveiro that sounds fine |
Input null values fix.