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 sanitizer()->date() outputting NULL for valid but falsey values #236

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

JanRomero
Copy link
Contributor

Hi,

this fixes three things:

  1. (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.

  2. (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.

  3. (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!

This fixes three things:

1. (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.

2. (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.

3. (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!
@JanRomero JanRomero closed this by deleting the head repository Oct 20, 2022
@JanRomero JanRomero reopened this Oct 29, 2022
@ryancramerdesign ryancramerdesign added the missing-CLA We do not have a ProcessWire contributor license agreement (CLA) for user that contributed the PR. label Jan 19, 2023
ryancramerdesign pushed a commit that referenced this pull request Jan 27, 2023
@ryancramerdesign
Copy link
Member

Thanks @JanRomero this has been added.

@ryancramerdesign ryancramerdesign added completed PR has been successfully added and this may be closed when ready. and removed missing-CLA We do not have a ProcessWire contributor license agreement (CLA) for user that contributed the PR. labels Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed PR has been successfully added and this may be closed when ready.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants