Fix sanitizer()->date() outputting NULL for valid but falsey values #236
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.
Hi,
this fixes three things:
(line 3807) $options['default'] was returned when the input was 0 or '0', although those are valid timestamps. Now it checks somewhat inelegantly whether an empty string (the only string satisfying “no value specified”) or an int (always a valid timestamp, or anyway always a value) were given.
(line 3818) NULL was returned when the intermediary timestamp happened to be 0, although 0 is a valid timestamp. Both branches give FALSE on unsuccessful conversion, so we should only fail if that’s the case.
(line 3835) NULL was returned when the final formatted value happened to be falsey. In my case I was checking for sundays with returnFormat “w”, which should give the string '0', but I got NULL. Now it only fails when the formatted value is unset or FALSE (even if I set the returnFormat to an empty string, I expect to get the empty string every time, unless the input was bad).
Thanks!