#25347 closed defect (bug) (fixed)
mysql2date() limitation for scheduled posts
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Date/Time | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
The latest Theme Unit Test data is available here for theme reviewers (and theme developers) to test against.
There is a post scheduled for year 2050. During the import process in wp_insert_post
there is this snippet:
} elseif( 'future' == $post_status ) { $now = gmdate('Y-m-d H:i:59'); if ( mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) ) $post_status = 'publish';
mysql2date
uses strtotime
and the future date could return false
which would update the status of the future post to publish
.
This is probably related to the date limitation for 32-bit systems, as described on php.net:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.)
Since that's still fine given the current date, it might be a minor issue, but it's being exposed in a use case such as the import process where a future post is being published instead while migrating to another site.
For that specific use case scenario adding a non-false check would help, but is probably an overhead:
if ( false !== mysql2date('U', $post_date_gmt, false) && mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) )
Attachments (1)
Change History (10)
#3
@
12 years ago
The Theme Reviewers team updated the Test data to 2020 to avoid issues until this one is resolved in some way.
#4
@
9 years ago
- Keywords needs-patch needs-unit-tests added
- Severity changed from minor to normal
The year 2038 problem is going to come up more and more.
#7
@
6 years ago
- Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
Changed to string comparison to not depend on int range and added unit test.
Introduced in [14062].