[wp-trac] [WordPress Trac] #56468: sanitize_option() does not handle deprecated timezones correctly

WordPress Trac noreply at wordpress.org
Mon Sep 19 23:46:40 UTC 2022


#56468: sanitize_option() does not handle deprecated timezones correctly
-------------------------------------------------+-------------------------
 Reporter:  jrf                                  |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  accepted
 Priority:  normal                               |   Milestone:  6.1
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing has-unit-    |     Focuses:
  tests commit                                   |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 In [changeset:"54229" 54229]:
 {{{
 #!CommitTicketReference repository="" revision="54229"
 Date/Time: Correct sanitization of `timezone_string` in
 `sanitize_option()`.

 This fixes a bug where if the `timezone_string` is set to a timezone name
 which has since been deprecated, the option value would be “lost” when
 saving the value again, as the comparison being done to verify whether it
 is a valid timezone name would only take “current” timezone names into
 account and would invalidate deprecated timezone names.

 By passing the `DateTimeZone::ALL_WITH_BC` constant as the
 `$timezoneGroup` parameter to the PHP native `timezone_identifiers_list()`
 function, a timezone name list is retrieved containing both current and
 deprecated timezone names, preventing the invalidation of the option
 value.

 See the extensive write-up about this in ticket #56468.

 Also see: [https://www.php.net/manual/en/datetimezone.listidentifiers.php
 PHP Manual: timezone_identifiers_list()].

 Includes adding a dedicated test to the data provider used in the
 `Tests_Option_SanitizeOption` test class.

 Note: The new data set is ''named'', even though the other data sets are
 unnamed, to make sure it is clear what this data set is testing. Adding
 test names for the original data sets in this data provider would be a
 great future improvement, but is outside of the scope of this commit.

 Follow-up to [18323], [33119], [54207], [54217], [54227].

 Props jrf, costdev.
 See #56468.
 }}}

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


More information about the wp-trac mailing list