[wp-trac] [WordPress Trac] #25347: mysql2date() limitation for scheduled posts

WordPress Trac noreply at wordpress.org
Wed Sep 18 00:21:21 UTC 2013


#25347: mysql2date() limitation for scheduled posts
--------------------------+-------------------------------
 Reporter:  nofearinc     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Date/Time     |    Version:  3.6.1
 Severity:  minor         |   Keywords:  reporter-feedback
--------------------------+-------------------------------
 The latest [http://codex.wordpress.org/Theme_Unit_Test Theme Unit Test]
 data is [https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-
 data.xml 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 [http://php.net/manual/en/function.strtotime.php 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) )
 }}}

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25347>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list