[wp-trac] [WordPress Trac] #4575: Add functions to return the last-modified timestamp of a category/tag
WordPress Trac
noreply at wordpress.org
Wed Feb 27 20:23:57 UTC 2019
#4575: Add functions to return the last-modified timestamp of a category/tag
-------------------------------------------------+-------------------------
Reporter: delusions | Owner:
| adamsilverstein
Type: enhancement | Status: assigned
Priority: normal | Milestone: 5.2
Component: Feeds | Version: 2.2.1
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests commit | Focuses: template
early |
-------------------------------------------------+-------------------------
Comment (by adamsilverstein):
@stevenkword - I reviewed the latest patch... this looks great and is very
close to ready.
I have a question about the use of `max` to find the latest date. This is
comparing the values in `post_modified_gmt` (or `comment_date_gmt`) which
are date string, eg `2019-02-27 19:49:41` - I think this works, but i
worry about potential edge cases where this string might not sort
correctly (for example a one digit month '2' could sort wrong against '11'
- although i ''think'' these datestrings will have '0's padding them).
string sorting can sometime have unexpected results.
Would it be worth converting these strings to numbers (timestamps) before
the call to `max` to ensure the sorting always works as expected? eg add
`$modified_time = array_map( 'strtotime', $modified_times );` then convert
back to a string before returning.
Also: I would love to see the tests expanded a bit if possible, ideally
creating posts in two categories so its clear category feeds
`lastModified` are updated independently (eg the test would fail before
the new helper)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/4575#comment:79>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list