Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#12560 closed defect (bug) (fixed)

occasional blog option corruption for serialized values

Reported by: rogertheriault's profile RogerTheriault Owned by: westi's profile westi
Milestone: 3.1 Priority: low
Severity: normal Version: 3.0.1
Component: Warnings/Notices Keywords: has-patch
Focuses: multisite Cc:

Description

get_blog_option sometimes / randomly returns nothing and corrupts/wipes out the entry for a serialized value. Seen as far back as WPMU 2.8, so this has been around. Traced it down to the call to unserialize - changed it to maybe_unserialize and the issue went away.

A patch for trunk is attached. Has only been tested on one installation.

Attachments (3)

get_blog_option_unserialize_patch.diff (538 bytes) - added by RogerTheriault 13 years ago.
get_blog_option_unserialize_patch.2.diff (556 bytes) - added by OpenHaus 13 years ago.
Check for an array and skip stripslash part
ms-blogs.php.patch (449 bytes) - added by mastermind 13 years ago.
One-liner, see comment 4

Download all attachments as: .zip

Change History (10)

#1 @Denis-de-Bernardy
13 years ago

  • Component changed from Multisite to Charset
  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 3.0 to Future Release
  • Owner set to hakre

patch is invalid. this is generally due to charset problems. WP is not multibyte safe, and neither are the underlying php functions.

punting this to future, since it'll probably never get solved before we get php6

#2 @nacin
13 years ago

  • Keywords multisite added

@OpenHaus
13 years ago

Check for an array and skip stripslash part

#3 @OpenHaus
13 years ago

  • Component changed from Charset to Warnings/Notices
  • Severity changed from minor to normal
  • Version changed from 3.0 to 3.0.1

I am also not able to retrieve an array saved as an option.

Warning: stripslashes() expects parameter 1 to be string, array given in /wordpress-3.0.1/wp-includes/ms-blogs.php on line 340

This is clearly a bug which needs to be handled. See get_blog_option_unserialize_patch.2.diff for a possible solution.

#4 @mastermind
13 years ago

The very simple solution would be to *not* use

if (! @unserialize( $value ) )
	$value = stripslashes( $value );

but

if (is_scalar( $value ) )
	$value = stripslashes( $value );

#5 @nacin
13 years ago

  • Milestone changed from Future Release to 3.1
  • Owner changed from hakre to westi
  • Status changed from new to assigned

@mastermind
13 years ago

One-liner, see comment 4

#6 @mastermind
13 years ago

  • Keywords has-patch added; needs-patch removed

#7 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [16808]) Remove stripslashes(). No longer needed. Props RogerTheriault. fixes #12560

Note: See TracTickets for help on using tickets.