Make WordPress Core

Opened 14 years ago

Closed 11 years ago

Last modified 11 years ago

#16504 closed enhancement (invalid)

Faster maybe_unserialize

Reported by: hakre's profile hakre Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: General Keywords: has-patch
Focuses: Cc:

Description

In #14429 many have taken care to optimize the is_serialized speed.

The function is of good general value and most often used to "maybe" unserialize.

It was originally smabauers who reminded that it's only about to check what it's about to check.

Option values, if serialized are only serialized Array, Objects or Strings. No exceptions. And they are always trimmed strings.

As is_serialized() is of general use and might be used by plugin authors, maybe_unserialize can get a new playmate.

Attachments (1)

16504.patch (1.7 KB) - added by hakre 14 years ago.
introducing is_serialized_maybe

Download all attachments as: .zip

Change History (13)

@hakre
14 years ago

introducing is_serialized_maybe

#1 @hakre
14 years ago

  • Type changed from defect (bug) to enhancement

#2 follow-up: @westi
14 years ago

Option values, if serialized are only serialized Array, Objects or Strings. No exceptions. And they are always trimmed strings.

This is an incorrect assumption - the API allows you to provide already serialised data if you want.

#3 in reply to: ↑ 2 ; follow-up: @hakre
14 years ago

Replying to westi:

Option values, if serialized are only serialized Array, Objects or Strings. No exceptions. And they are always trimmed strings.

This is an incorrect assumption - the API allows you to provide already serialised data if you want.

Well that's what for the "or Strings" part of my sentence is about. You must have just missed it, my sentence is very correct indeed.

#4 in reply to: ↑ 3 ; follow-up: @westi
14 years ago

Replying to hakre:

Replying to westi:

Option values, if serialized are only serialized Array, Objects or Strings. No exceptions. And they are always trimmed strings.

This is an incorrect assumption - the API allows you to provide already serialised data if you want.

Well that's what for the "or Strings" part of my sentence is about. You must have just missed it, my sentence is very correct indeed.

No it's not - what about serialized integers?

#5 in reply to: ↑ 4 ; follow-up: @hakre
14 years ago

Replying to westi:

Replying to hakre:

Option values, if serialized are only serialized Array, Objects or Strings. No exceptions. [...]

No it's not - what about serialized integers?

I've created a table in my post Serialization in Options: Cant see the Wood for the Trees that handles each data case and tells whether it is serialized in options or not. It's the first table.

The "Option Values" I talk about are those that come from the database, not those that are returned by get_option(). That function will always return the unserialized value, in case of your serialized integer, the serialized integer.

If you look into the code of the patch, it becomes clear about what functions this is about.

Does this helps to better understand?

#6 in reply to: ↑ 5 ; follow-up: @westi
14 years ago

Replying to hakre:

Replying to westi:

Replying to hakre:

Option values, if serialized are only serialized Array, Objects or Strings. No exceptions. [...]

No it's not - what about serialized integers?

I've created a table in my post Serialization in Options: Cant see the Wood for the Trees that handles each data case and tells whether it is serialized in options or not. It's the first table.

The "Option Values" I talk about are those that come from the database, not those that are returned by get_option(). That function will always return the unserialized value, in case of your serialized integer, the serialized integer.

If you look into the code of the patch, it becomes clear about what functions this is about.

Does this helps to better understand?

Not really.

You are still making an assumption: You are assuming that the only place maybe_unserialize is ever used is for unserializing things which have been maybe_serialized - you are changing it's behaviour by not supporting all types of serialized data.

It has had this behaviour since WordPress 2.0 - we are not going to break it!

#7 in reply to: ↑ 6 @hakre
14 years ago

Replying to westi:

You are still making an assumption: You are assuming that the only place maybe_unserialize is ever used is for unserializing things which have been maybe_serialized - you are changing it's behaviour by not supporting all types of serialized data.

That's no argument against the enhancement itself. If maybe_unserialize is not the right place for that enhancement, it's easy to find that right place.

It has had this behaviour since WordPress 2.0 - we are not going to break it!

I never said I want to break it, keep cool.

#8 @hakre
14 years ago

Related: #17375

#9 @c3mdigital
11 years ago

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

If this is still an issue please reopen and be prepared with unit tests to support. See comment:6

#10 @nacin
11 years ago

  • Resolution changed from wontfix to invalid

This also has security implications. So, no.

#11 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted

#12 @SergeyBiryukov
11 years ago

#26521 was marked as a duplicate.

Note: See TracTickets for help on using tickets.