#47777 closed defect (bug) (fixed)
"get_lastpostmodified" does not seem to return the intended value when using custom post types
Reported by: | mikaumoto | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
When I use "get_lastpostmodified" for custom post type,the return value was different from what I thought.
ex.post_type wp,tips
sql
SELECT post_modified FROM wp_posts WHERE post_type='%s' and post_status='publish' order by post_modified DESC limit 1
SELECT post_date FROM wp_posts WHERE post_type='%s' and post_status='publish' order by post_date DESC limit 1
wp-includes\post.php
<?php $lastpostdate = get_lastpostdate( $timezone ); if ( $lastpostdate > $lastpostmodified ) { $lastpostmodified = $lastpostdate; }
If understand that when "modified" is older "posted" return value is "posted".
But "lastpostdate" seems "any post_types", I think.
I tried this code.
<?php $lastpostdate = get_lastpostdate( $timezone, $post_type ); if ( $lastpostdate > $lastpostmodified ) { $lastpostmodified = $lastpostdate; }
As above, I think "get_lastpostmodified" will return the intended value.
I would like you to consider this matter.
Thank you.
Attachments (6)
Change History (19)
#2
@
5 years ago
- Keywords needs-unit-tests added
- Milestone changed from Awaiting Review to 5.4
- Version set to 4.4
Thanks for the report @mikaumoto and thanks for the patch @munyagu.
That patch looks good but this could do with some unit tests.
#3
follow-up:
↓ 4
@
5 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
Thanks @mikaumoto and @munyagu for your efforts on this ticket. @johnbillion I added unit test in 47777.2.diff. Let's try to include this in 5.4
if possible.
#4
in reply to:
↑ 3
@
5 years ago
Replying to donmhico:
Thanks @mikaumoto and @munyagu for your efforts on this ticket. @johnbillion I added unit test in 47777.2.diff. Let's try to include this in
5.4
if possible.
Thanks!
#5
@
5 years ago
Hi there,
With Beta 3 approaching, we'll need a decision and a commit action very soon.
For Component maintainers: if you don't feel the current patch is ready to land in WP 5.4 in the next few day, it's could be better to move it to 5.5. We're leaving it in the milestone for now.
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
#9
@
5 years ago
- Milestone changed from 5.4 to 5.5
With 5.4 RC1 landing tomorrow, this is being moved to 5.5
. If any maintainer or committer feels this can be resolved in time or wishes to assume ownership during a specific cycle, feel free to update the milestone.
#10
@
5 years ago
47777.2.diff looks good, however, if we're adding the $post_type
parameter to the get_lastpostmodified
filter, the same should be done for get_lastpostdate
.
add $post_type