[wp-trac] Re: [WordPress Trac] #9930: is_serialized() returns false
on serialized doubles
WordPress Trac
wp-trac at lists.automattic.com
Mon May 25 07:15:46 GMT 2009
#9930: is_serialized() returns false on serialized doubles
---------------------------------+------------------------------------------
Reporter: vladimir_kolesnikov | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.8
Component: General | Version:
Severity: minor | Keywords: has-patch
---------------------------------+------------------------------------------
Comment(by vladimir_kolesnikov):
Replying to [comment:2 Denis-de-Bernardy]:
> you sure you changed the correct function? it doesn't seem to answer
true only only on strings now.
Not sure I understood your question (English is not my native language)
but:
1. is_serialize() returns false if $data is not a string;
2. the regexp is three in one (N;, [aOs]:[0-9]+:.*[;}],
[bid]:[0-9.E+-]+;), the third regexp contains '+', since serialized
doubles can contain '+' after 'E'
Test case:
{{{
<?php
require_once('wp-load.php');
function is_serialized2($data)
{
return is_string($data) &&
preg_match('/^((N;)|([aOs]:[0-9]+:.*[;}])|([bid]:[0-9.E+-]+;))$/s',
$data);
}
print var_export(is_serialized2(serialize("a\nb"))) . "\n";
print var_export(is_serialized2(serialize(-25))) . "\n";
print var_export(is_serialized2(serialize(25))) . "\n";
print var_export(is_serialized2(serialize(false))) . "\n";
print var_export(is_serialized2(serialize(null))) . "\n";
print var_export(is_serialized2(serialize(array()))) . "\n";
print var_export(is_serialized2(serialize(1.1))) . "\n";
print var_export(is_serialized2(serialize(2.1E+200))) . "\n";
$x = new stdClass();
$x->a = 1;
$x->b = 'test';
print var_export(is_serialized2(serialize($x))) . "\n";
?>
}}}
Expected result:
{{{
true
true
true
true
true
true
true
true
true
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9930#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list