WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7133 closed defect (bug) (fixed)

maybe_serialize does not match with maybe_unserialize

Reported by: hakre Owned by: westi
Milestone: 2.6 Priority: high
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

maybe_serialize is used in conjunction with maybe_unserialize. from a logical point of view, data passed through both functions should be returned unchanged:

<?php
$data_original = ' original ';
$data = maybe_serialize($data_original);
$data = maybe_unserialize($data);

printf('Original:"%s" Processed:"%s"', $data_original, $data);
?>

the output is:
Original:" original " Processed:"original"

this example shows that data has been unecessarily manipulated.

when you look into the code you can see that maybe_serialize() trims the $data. this is of no use.

# to trim a string use trim() php function
# serialization is about arrays and objects, not strings

Attachments (2)

patch-r8069-7133-00.txt (517 bytes) - added by hakre 9 years ago.
Patch so solve the Problem
patch-r8069-7133-00.patch (517 bytes) - added by hakre 9 years ago.
Simply no need to trim(), fixes #7133

Download all attachments as: .zip

Change History (7)

@hakre
9 years ago

Patch so solve the Problem

@hakre
9 years ago

Simply no need to trim(), fixes #7133

#1 @hakre
9 years ago

  • Owner changed from hakre to westi

The solution is so simple like easy. There is no need to trim string data, so here it goes.

westi can you take a look?

#2 @ryan
9 years ago

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

(In [8100]) Don't trim strings in maybe_serialize(). Props hakre. fixes #7132 #7133 #4781 for trunk

#3 @ryan
9 years ago

(In [8101]) Don't trim strings in maybe_serialize(). Props hakre. fixes #7132 #7133 #4781 for 2.5

#4 @ryan
9 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

#5 @westi
9 years ago

  • Milestone changed from 2.9 to 2.6
Note: See TracTickets for help on using tickets.