[wp-trac] [WordPress Trac] #57035: Error in current_time() function when using timestamp and no value for gmt_offset
WordPress Trac
noreply at wordpress.org
Wed Oct 11 19:35:19 UTC 2023
#57035: Error in current_time() function when using timestamp and no value for
gmt_offset
-------------------------------------------------+-------------------------
Reporter: Nick_theGeek | Owner: audrasjb
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 6.5
Component: Date/Time | Version: 5.3
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
testing php80 dev-feedback |
-------------------------------------------------+-------------------------
Comment (by rleeson):
Can you please qualify what is the "lack of test coverage" referenced
above?
The PR adds test class `Tests_Date_CurrentGmtOffset` to cover various
option values:
- Non-numeric string => 0
- Boolean true => 0
- Uninitialized/Unset Option => 0
- Float => Float
This does replace a call inside of `current_time` which then casts to
`int`, though this only was a preexisting cast and its set of tests also
continue to pass.
If there is some additional context or criteria about what needs to be
added, I can add some more tests.
----
RE: The functionality choices and interface - This could add a temporary
variable storage and type check prior to avoid any potential issues with
an array or object stored to the option.
Also, can contributors start adding return types to functions? As a new
function, it seems a good candidate.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57035#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list