WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#4781 closed defect (bug) (fixed)

update_option destroys value / faulty trim

Reported by: hakre Owned by:
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.2.2
Component: Administration Keywords: update_option trim has-patch
Focuses: Cc:

Description

When using wordpress option function "update_option" and the value of the option is a string containing trailing spaces (wether in front or at the end), these spaces will be removed. This can destroy the option value since spaces are chars like any other chars in a string. The option value then is saved crippeled into the option system and each time the value is requested again trailing spaces are missing.

The defect is inside the update_option() function on line 281 in functions.php. In line 289 the option value type is checked to be a string and if it is a string, the string value will be trimmed:

if ( is_string($newvalue) )
		$newvalue = trim($newvalue);

It is totally unclear why this happens, the sourcecode isn't documented in any way. I applied a diff against the current SVN that removes these two lines of faulty code.

Attachments (1)

4781.diff (534 bytes) - added by hakre 7 years ago.

Download all attachments as: .zip

Change History (10)

hakre7 years ago

comment:1 hakre7 years ago

  • Keywords has-patch added

comment:2 markjaquith7 years ago

  • Milestone changed from 2.2.3 to 2.4 (future)

This is likely legacy code. I have no problem axing it.

comment:3 westi6 years ago

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

(In [6367]) Remove triming from string options fixes #4781 props hakre

comment:4 hakre6 years ago

  • Cc westi added
  • Resolution fixed deleted
  • Status changed from closed to reopened

There is a regression on this bug. The usage of maybe_serialize() which was not in there the time this was fixed, leads to a trim _again_.

See #7132

comment:5 ryan6 years ago

  • Milestone changed from 2.5 to 2.5.2

comment:6 ryan6 years ago

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

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

comment:7 ryan6 years ago

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

comment:8 ryan6 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:9 westi6 years ago

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