Opened 7 months ago
Last modified 2 weeks ago
#63835 new defect (bug)
Admin pages listing displays post time instead of modified time for posts with status not equal "published"
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.8.2 |
| Component: | Administration | Keywords: | has-patch |
| Focuses: | Cc: |
Description
In the admin pages listing (table) the "Date" column displays a wrong date for pages with another post_status than "published": eg. "modified", "draft", "private".
For modified pages it correctly displays the label "Last Modified" but the wrong post time instead of the expected modified time.
Reason:
In file wp-admin/includes/class-wp-posts-list-table.php in line 1222 the label/status is set, but the $t_time from some lines above is still the post time.
Suggested fix:
Change from this
} else {
$status = __( 'Last Modified' );
}
to this, retrieving the modified date in this case:
} else {
$status = __( 'Last Modified' );
$t_time = sprintf(
/* translators: 1: Modified date, 2: Modified time. */
__( '%1$s at %2$s' ),
/* translators: Modified date format. See https://www.php.net/manual/datetime.format.php */
get_the_modified_time( __( 'Y/m/d' ), $post ),
/* translators: Modified time format. See https://www.php.net/manual/datetime.format.php */
get_the_modified_time( __( 'g:i a' ), $post )
);
}
Change History (6)
This ticket was mentioned in PR #9501 on WordPress/wordpress-develop by @abcd95.
7 months ago
#1
- Keywords has-patch added
#3
@
7 months ago
One comment regarding your above mentioned patch in PR #9501:
Now there are two places where the status (publish, future) is checked for.
First in your new line
$use_modified_time = ! in_array( $post->post_status, array( 'publish', 'future' ), true );
and a couple of lines later in the original if/elseif/else statement.
That's working but it might get out of sync easily in future changes.
Conclusion:
There is always more than one way to solve a problem! ;-)
#4
@
7 months ago
- Keywords needs-testing removed
Test Report
Description
✅ This report validates whether the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/9501
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Actual Results
- ✅ Issue resolved with patch.
Additional Notes
Before applying the patch, I noticed the sequence of changes in post status affects dates.
- From a fresh post (not yet published or made private), changes to draft, pending, or scheduled correctly update scheduled/modified dates (publish time remains immediate or at scheduled time)
- Once set to private or published, the publish date resets to the current time, and later any changes to draft, pending and private shows an incorrect modified date (stuck at the private/published conversion).
The patch correctly handles all non-scheduled/unpublished cases, so this shouldn't matter, but this sequence difference may explain why it only seemed to affect private posts for @abcd95 while other states for @gchriz
@circlecube commented on PR #9501:
7 months ago
#5
I reproduced this issue by creating a few pages and changing the publish date, and then saving as a draft (or scheduled). I indicated in the page title when the publish date is and when it was last modified. Here is the issue reproduced on core in latest on playground (not the PR code):
The date this was created is 8/26, so yesterday refers to 8/25, but the post was just edited.
Then I opened the PR "Test in Playground" and created the same pages for this screenshot to show the changes to fix the issue. The posts now display the last modified date in favor of the publish date (even though they are not published):
This may be by design to show the "publish" data for draft posts, but if so, the label is incorrect. Not sure the best UX when a post has a publish date set, but the last modified date is different - should it show last modified or the desired publish date? Either way, though, either the label or the date data needs to be updated, since the label does not match the data. Either we need to update the date data, as this PR does to match the label of "Last Modified" or the label should be updated.
I think the last modified data is more relevant than the publish data since the page is not published yet (so publish date is irrelevant).
Thanks @gchriz for the ticket.
I was able to reproduce the issue for private post statuses. However, drafts and pending were working fine for me. While the patch suggested works, it makes the function unintuitive in my opinion.
I have developed an alternative patch that keeps the context and functional flow in mind.