[wp-trac] [WordPress Trac] #48319: About wp_date function when locale is 'ja'

WordPress Trac noreply at wordpress.org
Wed Oct 16 09:41:46 UTC 2019


#48319: About wp_date function when locale is 'ja'
--------------------------+---------------------
 Reporter:  tmatsuur      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.3
Component:  Date/Time     |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+---------------------

Comment (by remcotolsma):

 I don't follow why `backslashit` adds backslashes before a number at the
 start of a string:
 https://github.com/WordPress/WordPress/blob/5.2/wp-
 includes/formatting.php#L2615-L2628

 Related commits:

 -
 https://github.com/WordPress/WordPress/commit/f1aeebf00b6a38fb1bd1bb30f19bd8fe8ac0361d
 -
 https://github.com/WordPress/WordPress/commit/f124c511077be7435ee4e5afafe46078224c06d1

 It looks like it was added after the following Trac ticket en WordPress
 support topic:

 - https://core.trac.wordpress.org/ticket/2774
 - https://wordpress.org/support/topic/1-prefixed-to-the-date-of-all-posts-
 after-203-upgrade/

 Back then it seems to be related to a Date/Time issue with `preg_replace`
 and older PHP versions. But since `preg_replace` is no longer used and
 WordPress requires PHP 5.6.20+ the `backslashit` function might even be
 simplified to:

 {{{#!php
 <?php

 function backslashit( $string ) {
         return addcslashes( $string, 'A..Za..z' );
 }

 }}}

 But I think using `addcslashes` with only the date format characters is
 also a nice fix for this problem.

 I have added a unit test to our own datetime library for this issue:
 https://github.com/pronamic/wp-
 datetime/commit/ff16527c5d7055c559dcf01760e6189f30044f42.

 And a fix:
 https://github.com/pronamic/wp-
 datetime/commit/09424a2c3585f495f8dd6ea880c400f557c475f9

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


More information about the wp-trac mailing list