Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#5459 closed defect (bug) (duplicate)

autosave creates new draft on each iteration

Reported by: nbachiyski Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3.1
Component: Administration Keywords: autosave has-patch
Focuses: Cc:


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();


Thanks to Krasimir Dobrev for experiencing and reporting this one.

Attachments (1)

autosave-array.diff (1.3 KB) - added by nbachiyski 13 years ago.

Download all attachments as: .zip

Change History (3)

#1 @santosj
13 years ago

  • Component changed from General to Administration

#2 @Denis-de-Bernardy
12 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This can happen on some php versions that incorrectly process charsets. It's related to things getting unsuccessfully unserialized, and it has been fixed in r10955

Note: See TracTickets for help on using tickets.