[wp-hackers] [GSOC2010]WPmove [wpurl] tag replace
Piyush Mishra
admin at oxymaniac.com
Thu Apr 8 17:30:26 UTC 2010
neat :) this helps in working for data now but what about the [wpurl] tag
thing?
On Thu, Apr 8, 2010 at 8:47 PM, Otto <otto at ottodestruct.com> wrote:
> On Thu, Apr 8, 2010 at 9:23 AM, Piyush Mishra <admin at oxymaniac.com> wrote:
> > I beg to differ, I tried printing the array out to my local server
>
> Huh. I'll be darned, you're right. I know it has worked for me before,
> but with a simple test I can't make it work again.
>
> Still, it's possible to add code to WP to fix that easily enough. If
> you alter the maybe_unserialize function in wp-includes/functions.php
> to the following, then the string lengths won't matter any more.
>
>
> function maybe_unserialize( $original ) {
> if ( is_serialized( $original ) ) // don't attempt to unserialize
> data that wasn't serialized going in
> {
> $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]);
> }
>
>
> Test that shows it works:
> $a ='a:2:{i:0;s:123:"Test";i:1;s:456:"Fake";}';
>
> var_dump(maybe_unserialize($a));
>
>
> -Otto
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
Regards
Piyush Mishra
More information about the wp-hackers
mailing list