Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#48207 new defect (bug)

Implement new Comment Date Functions

Reported by: dshanske's profile dshanske Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: needs-unit-tests dev-feedback
Focuses: Cc:


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)

48207.diff (5.5 KB) - added by dshanske 5 years ago.

Download all attachments as: .zip

Change History (5)

#1 @Rarst
5 years ago

Makes sense, just didn't get to it yet. :)

5 years ago

#2 @dshanske
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 @Rarst
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 @dshanske
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.

Note: See TracTickets for help on using tickets.