Search code examples
phparrayssimplexmlapc

APC Caching array of SimpleXMLElement objects


I'm having difficulty caching an array of SimpleXMLElement objects. It's the apc_store line that fails, and I'm not sure why.

The program terminates at this line, which is strange because I've used this elsewhere --- wrapping an array in a ArrayObject and storing it in the cache.

My code extract is below:

    $feed = /* some url */
    $xml = simplexml_load_file($feed);
    $items = $xml -> xpath('/rss//item');

    foreach($items as $item){
        $item -> addChild('myTag1', "My Tag 1");
        $item -> addChild('myTag2', "My Tag 2");
    }

    apc_store($feed, new ArrayObject($items), 60);

I don't think my log file is working correctly, this is the last entry, just in case it helps but I think it's to do with SSL and not helpful here:

[Wed Feb 20 12:21:51 2013] [notice] caught SIGTERM, shutting down
Attempt to free unreferenced scalar: SV 0x7fe7805e2130, Perl interpreter: 0x7fe7805ea4f0 during global destruction.
[Wed Feb 20 12:21:54 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Feb 20 12:21:54 2013] [notice] SSL FIPS mode disabled
Attempt to free unreferenced scalar: SV 0x7f94bfa75ec0, Perl interpreter: 0x7f94bfa56550 during global destruction.
[Wed Feb 20 12:21:57 2013] [notice] Digest: generating secret for digest authentication ...
[Wed Feb 20 12:21:57 2013] [notice] Digest: done
[Wed Feb 20 12:21:59 2013] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Wed Feb 20 12:21:59 2013] [notice] mod_python: using mutex_directory /tmp 
[Wed Feb 20 12:21:59 2013] [notice] SSL FIPS mode disabled
[Wed Feb 20 12:21:59 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.4.10 mod_python/3.3.1    Python/2.7.3 mod_ssl/2.2.22 OpenSSL/1.0.0j-fips mod_perl/2.0.5 Perl/v5.14.3 configured -- resuming   normal operations

Thanks for all your help.


Solution

  • In the example above, $feed was not a string representation of a url; it was an array, whose first element was a string representation of a url. Also, in addition, I was using namespaces so ArrayObject needed a slash prefix.