[wp-trac] [WordPress Trac] #5459: autosave creates new draft on each iteration

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 12 09:49:30 GMT 2007


#5459: autosave creates new draft on each iteration
------------------------+---------------------------------------------------
 Reporter:  nbachiyski  |       Owner:  anonymous         
     Type:  defect      |      Status:  new               
 Priority:  normal      |   Milestone:  2.4               
Component:  General     |     Version:  2.3.1             
 Severity:  normal      |    Keywords:  autosave has-patch
------------------------+---------------------------------------------------
 Expected behaviour: on each auto-save the current post is saved

 Current behaviour for some users:

 For some users (I can't reproduce) every time a draft is auto-saved it
 fails with errors like:
 {{{
 Warning: Invalid argument supplied for foreach() in .../blog/wp-admin
 /admin-functions.php on line 30

 Warning: array_search() [function.array-search]: Wrong datatype for second
 argument in .../blog/wp-admin/admin-functions.php on line 117

 Warning: Illegal string offset: -1197443547 in .../blog/wp-admin/admin-
 functions.php on line 124
 }}}

 As a result on each auto-save a new draft is created.

 Cause: somehow the {{{autosave_draft_ids}}} options is both true and not
 an array and the default value isn't used:
 {{{
 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
     $draft_ids = array();
 }}}

 Solution: if {{{$draft_ids}}} isn't tested in boolean, but in array
 context everything is fine:
 {{{
 if ( !is_array( $draft_ids = get_user_option( 'autosave_draft_ids' ) ) )
     $draft_ids = array();
 }}}

 Patch-attached.

 Thanks to Krasimir Dobrev for experiencing and reporting this one.

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


More information about the wp-trac mailing list