Opened 9 months ago
Closed 8 months ago
#63207 closed defect (bug) (fixed)
Docs: Enhance inline documentation for current_time, wp_date, and date_i18n functions/filters.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Date/Time | Keywords: | has-patch has-unit-tests |
| Focuses: | docs | Cc: |
Description
- The
$gmtargument in thecurrent_timefunction accepts a boolean valuetrue|false - The
$timestampand$timezonearguments in thewp_datefunction acceptnull, but this is not documented inline. - The
date_i18nfilter documentation includes "Default false," but it seems unnecessary. Ref: https://tinyurl.com/236y7b5u
Change History (10)
This ticket was mentioned in PR #8625 on WordPress/wordpress-develop by @dilipbheda.
9 months ago
#1
#3
@
9 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
#4
follow-up:
↓ 7
@
9 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
[60119] is more than just a docs change, and there are unit tests that pass a non-boolean value to this function (test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC(), test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC(), maybe others) that should be updated. Functionally it's fine because that parameter is really a boolean, but let's be careful about calling something a docs change when it's technically more than that.
#5
follow-up:
↓ 6
@
9 months ago
@johnbillion Thanks for pointing this out! I checked and found that the core also uses the 1|0 value in some places, so it's possible that other plugins/themes use it as well.
You can check this here: https://github.com/search?q=repo%3AWordPress%2Fwordpress-develop+current_time%28+%27mysql%27%2C+&type=code
From my perspective, we should revert the @param type from bool to int|bool
What do you think?
cc @SergeyBiryukov
#6
in reply to:
↑ 5
@
9 months ago
Replying to dilipbheda:
From my perspective, we should revert the
@paramtype frombooltoint|bool
What do you think?
I think bool is fine here, and is more consistent with the same parameter in date_i18n(). Let's update the instances in core and unit tests to pass true instead of 1 for consistency. It's OK if some plugins or themes would still pass 1, as the function just checks for a truthy value.
#7
in reply to:
↑ 4
@
9 months ago
Replying to johnbillion:
Functionally it's fine because that parameter is really a boolean, but let's be careful about calling something a docs change when it's technically more than that.
Good point, thanks!
This ticket was mentioned in PR #8644 on WordPress/wordpress-develop by @dilipbheda.
9 months ago
#8
- Keywords has-unit-tests added
In 60119: