[wp-trac] [WordPress Trac] #28992: mysql2date() return empty string not false sometimes added doing it wrong message

WordPress Trac noreply at wordpress.org
Wed Aug 28 16:51:25 UTC 2019


#28992: mysql2date() return empty string not false sometimes added doing it wrong
message
--------------------------------------+---------------------
 Reporter:  pbearne                   |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:
Component:  Date/Time                 |     Version:  3.8
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------
Changes (by Rarst):

 * keywords:  needs-testing dev-feedback has-patch has-unit-tests => has-
     patch has-unit-tests


Comment:

 Ok, added a patch with fresh look in unit tests and revamp for the
 function.

 My thinking is this function is only ever meant to eat MySQL formatted
 times. As with many other date/time functions it will accept other stuff,
 but in this case you are definitely on your own if you are doing strange
 things with it.

 For same reason I dropped doing it wrong, since I don't think this
 warrants special handling and messaging.

 I focused unit tests accordingly and made `false` return for any input
 that `date_create()` couldn't deal with.

 I also re-documented it, since documentation was really just making
 confusing claims about what it does. While `G` and `U` were supposed to be
 somehow different timestamp return, in practice code produced exactly same
 return for them.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/28992#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list