[wp-trac] [WordPress Trac] #23954: Checkbox value is not updated correctly inside media-views.js

WordPress Trac noreply at wordpress.org
Fri Apr 5 22:11:19 UTC 2013


#23954: Checkbox value is not updated correctly inside media-views.js
-----------------------------+--------------------------
 Reporter:  NumberKruncher   |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Media
  Version:  3.5.1            |   Severity:  major
 Keywords:  needs-patch      |
-----------------------------+--------------------------
 I added two custom fields to the "Edit Gallery" interface using a hook and
 discovered that my "select" and "text" inputs were working fine, but my
 "checkbox" input did not work at all.

 I enabled `SCRIPT_DEBUG` so that I could explore further and discovered
 that the bug on line 3939 of media-views.js.

 A double-bang has been incorrectly used to cast from a string encoded
 boolean value to an actual boolean value (since !!"false" is actually
 true).

 This is the current implementation:

 {{{
 } else if ( $setting.is('input[type="checkbox"]') ) {
     $setting.attr( 'checked', !! value );
 }
 }}}

 This is my recommendation which resolves the issue:

 {{{
 } else if ( $setting.is('input[type="checkbox"]') ) {
     value = value !== false && value !== 'false';
     $setting.attr( 'checked', value );
 }
 }}}

 I would submit a patch, but I do not know how to do that.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23954>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list