Made changes in dearch by date logic.
Details
Preparation
- go to Website & Content → Labels & Phrases section
- modify some phrase, if all minutes or days in the "Modified On" column are equal
- confirm, that are visible records with different minutes and different days in the "Modified On" column
Date/Time configuration - for current language set:
- "Date Format" to Y-m-d
- "Time Format" to H:i:s
- "Input Date Format" to m/d/Y
- "Input Time Format" to g:i:s A
Testing "Modified On" column filter
- specify one from date only (no time)
- confirm, that records with other dates are filtered out
- specify one to date only (no time)
- confirm, that records with other dates are filtered out
- specify one to date only (with time)
- confirm, that records with other dates or minutes are filtered out (ignoring seconds)
- specify one from date only (with time)
- confirm, that records with other dates or minutes are filtered out (ignoring seconds)
- specify both from & to dates with time
- confirm, that records with dates between specified datetimes (ignoring seconds) are visible, but other are filtered out
- specify both from & to dates with time in output format (without seconds)
- confirm, that records with dates between specified datetimes (ignoring seconds) are visible, but other are filtered out
- specify both from & to dates with time in input format (with seconds)
- confirm, that records with dates between specified datetimes (ignoring seconds) are visible, but other are filtered out
- specify word "test" in place of from date and empty to date
- confirm, that no records found
- specify word "test" in place of to date and empty from date
- confirm, that no records found
- specify word "test" in place of from date and existing among records to date
- confirm, that no records found
- specify word "test" in place of to date and existing among records from date
- confirm, that no records found
- in search filter specify date using format from "Input Date Format" field without time (m/d/Y)
- confirm that right search results are shown
Diff Detail
- Repository
- rINP In-Portal
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
core/units/helpers/search_helper.php | ||
---|---|---|
605 ↗ | (On Diff #863) | NOTE: battle against malformed dates entered by user
change into: if ( is_numeric($from) && $to === null ) { this way to date entered in incorrect format won't be handled as to date not specified |
606 ↗ | (On Diff #863) |
$from == strtotime(date('Y-m-d', $from) . ' 00:00:00', $from) into date('H:i:s', $from) == '00:00:00'
|
610 ↗ | (On Diff #863) | NOTE: battle against malformed dates entered by user
change into: if ( $from === null && is_numeric($to) ) { this way from date entered in incorrect format won't be handled as from date not specified |
611 ↗ | (On Diff #863) |
$to == strtotime(date('Y-m-d', $to) . ' 00:00:00', $to) into date('H:i:s', $to) == '00:00:00'
|
617–620 ↗ | (On Diff #863) | NOTE: battle against malformed dates entered by user
change into: if ( is_numeric($from) && $to === null || $from === null && is_numeric($to) ) { $from = $from === null ? $to : $from; $to = $from; } this way we won't replace malformed from/to date entered by user with to/from date, that user entered correctly |
622 ↗ | (On Diff #863) | NOTE: battle against malformed dates entered by user
change into: if ( is_numeric($from) && is_numeric($to) ) { this way only correctly entered dates would be used in filter |
622–626 ↗ | (On Diff #863) | NOTE: battle against malformed dates entered by user
Please add else statement, that would set $filter_value variable value to FALSE (as string). this way if we've submitted filter with incorrectly formatted date, then we'll see 0 records instead of all records |
687 ↗ | (On Diff #863) | NOTE: battle against malformed dates entered by user
return null instead of false this way recipient would know if user haven't specified any value |
717–719 ↗ | (On Diff #863) | remove else statement, but keep the code inside it since code inside else statement is always executed it's pointless to wrap return ... statements with it |
The inline comments with NOTE: battle against malformed dates entered by user line above them are actually UX discovered issues, that weren't part of original task, but without fixing them user would be as confused as now thinking that date entered in incorrect format is actually working as filter, when it's not.
Please also update test plan to reflect handling of incorrectly entered dates.
core/units/helpers/search_helper.php | ||
---|---|---|
686 ↗ | (On Diff #865) |
When performing recursive method call the altered $value argument (trimmed & time added, when specified by user) is given and that results in the parsing error. Test plan fragment to cover this:
|
core/units/helpers/search_helper.php | ||
---|---|---|
695–703 ↗ | (On Diff #865) | With current test plan this code is never executed on recursive call to this method. I recommend debugging actual code to verify, that it works. |