[wp-trac] [WordPress Trac] #9663: is_serialized() should be renamed to might_be_serialized();
WordPress Trac
wp-trac at lists.automattic.com
Sun Jan 10 05:07:10 UTC 2010
#9663: is_serialized() should be renamed to might_be_serialized();
--------------------------+-------------------------------------------------
Reporter: hakre | Owner: anonymous
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 2.9
Component: Charset | Version: 2.7.1
Severity: normal | Resolution: wontfix
Keywords: has-patch |
--------------------------+-------------------------------------------------
Changes (by hakre):
* keywords: => has-patch
Comment:
Replying to [comment:10 sirzooro]:
> PCRE functions in PHP 4.3 are utf-8-aware - excerpt from
[http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php PHP
documentation for Pattern Modifiers]:
>
> >u (PCRE8)[[BR]]
> >This modifier turns on additional functionality of PCRE that is
incompatible with Perl. Pattern strings are treated as UTF-8. This
modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3
on win32. UTF-8 validity of the pattern is checked since PHP 4.3.5.
>
>
> So in 4.3 we do not have checks for utf-8 pattern validity, but
functionality is present.
That's right, but actually I did not see a problem with the regex pattern
here but with the design of the function / concept in which this function
is used in. Technically spoken there is no other way to ensure that a
string is a serialized value then de-serializing it and in case it returns
false, to re-check the given string if it contains the serialized value of
false {{{"b:0;"}}} or not.
Slight improvements to the function can be made to differ between
array/object and string.
I took the oportunity to review the function again:
* The function does a trim() on the input data. If the input data is
serialized, there would be no need to trim the data for a propper test. I
should be removed.
* Serialized data can somehow be large. Passing it per reference might
save a bit.
* The identification of the main type being serialized was a bit akward.
Streamlined it.
* Array, Object and String could be better tested.
To improve the overall concept, a function can be created that not only
returns true or false but the main serialized vartype as string. Most
often serialization is used to store arrays or object into the database.
With such a function, it could be differed between skalar types on the one
and object/arrays on the other side. So if a value from database is
retrieved that could be a serialized string then this would be a hint,
that the value acutally is not serialized.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9663#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list