[wp-trac] [WordPress Trac] #28637: get_theme_mod returns empty string instead of default

WordPress Trac noreply at wordpress.org
Sun Oct 18 18:07:34 UTC 2015


#28637: get_theme_mod returns empty string instead of default
--------------------------------------------+-----------------------------
 Reporter:  philipjohn                      |       Owner:  valendesigns
     Type:  defect (bug)                    |      Status:  assigned
 Priority:  normal                          |   Milestone:  4.4
Component:  Customize                       |     Version:  3.9.1
 Severity:  normal                          |  Resolution:
 Keywords:  has-patch has-unit-tests close  |     Focuses:  administration
--------------------------------------------+-----------------------------
Changes (by obenland):

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


Comment:

 Replying to [comment:23 valendesigns]:
 > why would an empty string override the default?

 Because it was explicitly set at some point. It even might have been set
 as a way to avoid returning the default value.

 > In what logical situation can we come up with that would make an empty
 string valid? I'm having a difficult time thinking of one. Can anyone
 present a case where an empty string would be the desired result and one
 which `false` could not be used as an alternative?

 We should not make assumptions about developers intent when they set a
 theme mod to an empty string. Why would an empty string not be a valid
 value? Setting a theme mod to anything should return that anything and not
 the default. IMO the default should only be returned if the theme mod was
 removed, which is the proper function in the API to invalidate it.

 > The only thing I can think of that is problematic is with user
 assumptions.
 Yet another reason to leave it as is, it has the potential to break
 backwards compatibility.

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


More information about the wp-trac mailing list