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

WordPress Trac noreply at wordpress.org
Tue Sep 20 01:00:39 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:"54233" 54233]:
 {{{
 #!CommitTicketReference repository="" revision="54233"
 Date/Time: Correct timezone dropdown list creation in
 `wp_timezone_choice()`.

 This fixes a bug where if the `timezone_string` is set to a timezone name
 which has since been deprecated, no option would be (pre-)selected in the
 generated dropdown list and when the form using the dropdown list is
 submitted, the “old”, originally saved value would be lost as the form
 would submit without a value being selected for the `timezone_string`
 field.

 The fix is a little hacky: it basically checks ahead of generating the
 actual dropdown list whether the `$selected_zone` value would be
 recognized and set to “selected” and if not, verifies that the value
 ''is'' a valid but outdated timezone name and if so, adds an extra
 dropdown entry to the top of the list with the original value and sets
 this value to “selected”.

 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()].

 Note: There are no pre-existing tests at all for this method and adding a
 complete set of tests for this method is outside the scope of this ticket,
 so this fix does not contain any tests.

 Follow-up to [54207], [54217], [54227], [54229], [54230], [54232].

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

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


More information about the wp-trac mailing list