[wp-trac] [WordPress Trac] #39811: Bug maybe_unserialize() broke mysql data.
WordPress Trac
noreply at wordpress.org
Mon Feb 20 06:34:59 UTC 2017
#39811: Bug maybe_unserialize() broke mysql data.
--------------------------+------------------------------
Reporter: ivijanstefan | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: 4.7.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by ivijanstefan):
I not fix this issue with any kind of database tools but I made an
workable solution for `maybe_unserialize()`:
{{{
function maybe_unserialize( $original ) {
$url = strtolower('http'.(isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) ? 's' :
'').'://'.@$_SERVER['HTTP_HOST'].@$_SERVER['REQUEST_URI']);
if(strpos($url,'plugins') !== false || strpos($url,'update-
core.php') !== false || strpos($url,'install') !== false || strpos($url
,'edit-comments.php') || strpos($url,'disqus') !== false ||
strpos($url,'comment') !== false || strpos($url,'discussion') !== false)
{
if ( is_serialized( $original ) ) // don't attempt to
unserialize data that wasn't serialized going in
return @unserialize( $original );
}
else
{
if ( is_serialized( $original ) ) {
$fixed = preg_replace_callback(
'!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s',
'serialize_fix_callback',
$original );
return @unserialize( $fixed );
}
}
return $original;
}
function serialize_fix_callback($match) { return 's:' . strlen($match[2]);
}
}}}
With this solution wordpress works well.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39811#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list