[glotpress-updates] [GlotPress] #484: Unable to pass active=0 to GP_Project->save()

GlotPress noreply at wordpress.org
Mon Aug 24 06:02:02 UTC 2015


#484: Unable to pass active=0 to GP_Project->save()
---------------------+-----------------
 Reporter:  dd32     |      Owner:
     Type:  defect   |     Status:  new
 Priority:  normal   |  Milestone:  1.0
Component:  General  |    Version:
 Keywords:           |
---------------------+-----------------
 At present if you have code similar to the following, it'll fail to update

 {{{
 $project = GP::$project->by_path( $project_path );
 $project->save( array( 'active' => 0 ) );
 }}}

 The cause is that `GP_Project::normalize_fields()` accepts `'on'` for the
 active parameter, and does a non-strict comparison. If you pass `0` in as
 active, it'll cast `on` to a int and `(int)"on"` is 0, so it'll mark the
 project as active:
 {{{
 if ( isset( $args['active'] ) ) {
         if ( 'on' == $args['active'] ) $args['active'] = 1;
         if ( !$args['active'] ) $args['active'] = 0;
 }
 }}}

--
Ticket URL: <https://glotpress.trac.wordpress.org/ticket/484>
GlotPress <https://glotpress.trac.wordpress.org>
Easy comin', easy goin'


More information about the glotpress-updates mailing list