Opened 5 years ago
Last modified 7 days ago
#48207 assigned defect (bug)
Implement new Comment Date Functions
Reported by: | dshanske | Owned by: | pbearne |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | dev-feedback has-patch has-unit-tests |
Focuses: | Cc: |
Description
WordPress 5.3 introduces get_post_datetime() and get_post_timestamp(). Suggesting that these be mirrored with the equivalent functions get_comment_datetime and get_comment_timestamp.
Attachments (1)
Change History (7)
#2
@
5 years ago
- Keywords needs-unit-tests dev-feedback added
The attachment introduces the get_comment_timestamp and get_comment_datetime functions that are basically copies of the post versions of same. It does change the signature of get_comment_time to allow passing through a comment, which mirrors get_post_time. The fact that get_comment_time only allowed for the current comment, yet get_comment_date allowed for the passing of any comment seemed an odd inconsistency.
#3
@
5 years ago
From quick look seems fine, given that it is mostly a copy of post version of functions and I really hope we ironed all of quirks out there. :)
Need thorough unit tests, since old stuff is really really quirky about timestamps and stuff. I can work on that, once I survive 5.3 release.
PS not sure about adding to API here, feels tad out of scope of the ticket. I need to go over existing functions tree for comments, I hadn't done that as thoroughly as for posts yet.
#4
@
5 years ago
@Rarst I tried to make it as close a copy as possible, figuring that once we ironed out if this is the approach, we could duplicate the same unit tests you did for the post versions of these functions.
As for adding to the API, I can understand the process issue of having it as a separate ticket, however, without it, you would have more duplicative code. And as mentioned, it brings get_comment_time in line with get_post_time in terms of behavior. It seems unnecessary to introduce a new function for this.
This ticket was mentioned in PR #7943 on WordPress/wordpress-develop by @pbearne.
7 days ago
#5
- Keywords has-patch has-unit-tests added; needs-unit-tests removed
Introduced comprehensive PHPUnit tests for the functions get_comment_datetime
and get_comment_timestamp
to ensure they handle various edge cases correctly, such as handling invalid or zero dates, respecting timezones, and managing future or very old dates. Also updated the implementation to integrate these functions within the existing comment time retrieval mechanism, enhancing accuracy and consistency of datetime operations in comments.
Trac ticket:
Makes sense, just didn't get to it yet. :)