Opened 19 years ago
Closed 17 years ago
#5459 closed defect (bug) (duplicate)
autosave creates new draft on each iteration
| Reported by: | nbachiyski | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Administration | Version: | 2.3.1 |
| Severity: | normal | Keywords: | autosave has-patch |
| Cc: | Focuses: |
Description
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.
Attachments (1)
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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