[wp-hackers] WordPress Transients API
Pete Mall
pete at jointforcestech.com
Sat Jan 2 22:32:04 UTC 2010
There is indeed a problem with SimpleXML serialization... I was able to work
around it by serializing the SimpleXML object before set_transient and using
the following code after get_transient:
unserialize( str_replace( array( 'O:16:"SimpleXMLElement":0:{}',
'O:16:"SimpleXMLElement":' ), array( 's:0:"";', 'O:8:"stdClass":' ), $str )
);
On Sat, Jan 2, 2010 at 2:06 PM, Peter Westwood <peter.westwood at ftwr.co.uk>wrote:
>
> On 2 Jan 2010, at 19:55, Pete Mall wrote:
>
> I'm having a problem with the WordPress transients API. I'm trying to save
>> a
>> SimpleXMLElement Object and I don't think it is being stored properly. Am
>> I
>> missing something or is there a problem handling SimpleXMLElement Objects?
>>
>>
>> 1. print_r <http://www.php.net/print_r>( $record ); // ==>
>>
>> SimpleXMLElement Object ( [name] => www [data] => 111.111.111.111 [ttl]
>> =>
>> 86400 [aux] => 0 [id] => 111111 [zone-id] => 111111 [record-type] => A
>> [active] => Y )
>> 2. set_transient( 'my_transient_001', $record, 60*2 );
>> 3. print_r <http://www.php.net/print_r>( get_transient(
>>
>> 'my_transient_001' ) ); // ==> SimpleXMLElement Object ( )
>>
>
> I think this is because the SimpleXMLElement objects don't support being
> serialized and unserialized.
>
> At least that is the impression I get from here:
> http://php.net/manual/en/function.simplexml-load-string.php
>
> Cheers
>
> westi
> --
> Peter Westwood
> http://blog.ftwr.co.uk | http://westi.wordpress.com
> C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list