php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61956 APC breaks simplexml in PHP 5.4
Submitted: 2012-05-05 21:10 UTC Modified: 2012-06-11 04:20 UTC
Votes:33
Avg. Score:4.5 ± 0.8
Reproduced:28 of 29 (96.6%)
Same Version:23 (82.1%)
Same OS:16 (57.1%)
From: pierre at archlinux dot de Assigned: rasmus
Status: Closed Package: APC (PECL)
PHP Version: 5.4.2 OS: Arch Linux
Private report: No CVE-ID:
 [2012-05-05 21:10 UTC] pierre at archlinux dot de
Description:
------------
Using simplexml fails with a warning like:

Warning: dom_import_simplexml(): Invalid Nodetype to import

I am using APC 3.1.10 and PHP 5.4.2. The issue does not appear when I downgrade to PHP 5.3.12.

This issue can easily be reproduced by running the example code found at http://www.php.net/manual/en/function.dom-import-simplexml.php

This breaks the symfony framework for example: https://github.com/symfony/symfony/issues/4185 (other distributions such as Fedora are affected as well)

Test script:
---------------
<?php

$sxe = simplexml_load_string('<books><book><title>blah</title></book></books>');

if ($sxe === false) {
    echo 'Error while parsing the document';
    exit;
}

$dom_sxe = dom_import_simplexml($sxe);
if (!$dom_sxe) {
    echo 'Error while converting XML';
    exit;
}

$dom = new DOMDocument('1.0');
$dom_sxe = $dom->importNode($dom_sxe, true);
$dom_sxe = $dom->appendChild($dom_sxe);

echo $dom->saveXML();

?>


Expected result:
----------------
<?xml version="1.0"?>
<books><book><title>blah</title></book></books>

Actual result:
--------------
Warning: dom_import_simplexml(): Invalid Nodetype to import in /home/pierre/public_html/testxml.php on line 10
Error while converting XML

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-09 23:53 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2012-05-09 23:53 UTC] rasmus@php.net
I am not able to reproduce this with the script in this report. Could you try 
current APC trunk?
 [2012-05-10 07:53 UTC] m dot rohnstock at googlemail dot com
not working with rev325484, too.
Using same OS.
 [2012-06-07 10:04 UTC] pavel dot murzakov at gmail dot com
Bug occurs only with PHP-FPM.
With CLI everything is ok.

CentOS 6.2
PHP 5.4.3 and APC 3.1.10
 [2012-06-07 10:07 UTC] pierre at archlinux dot de
Note that APC is usually disabled in CLI mode. You can test with the built-in webserver though.
 [2012-06-07 10:45 UTC] pavel dot murzakov at gmail dot com
I've checked test script with built-in webserver.

#php -d "apc.enabled=1" -S localhost:8000
PHP 5.4.3 Development Server started at Thu Jun  7 14:36:45 2012


#curl http://localhost:8000/apc_sxml_test.php
Warning: dom_import_simplexml(): Invalid Nodetype to import in 
/home/pavel/apc_sxml_test.php on line 10

webserver log:
[Thu Jun  7 14:36:47 2012] PHP Warning:  dom_import_simplexml(): Invalid 
Nodetype to import in /home/pavel/apc_sxml_test.php on line 10
[Thu Jun  7 14:36:47 2012] ::1:37578 [200]: /apc_sxml_test.php


Bug also happens
 [2012-06-11 04:20 UTC] rasmus@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: rasmus
 [2012-06-11 04:20 UTC] rasmus@php.net
This should be fixed in SVN now.
 [2012-08-30 21:57 UTC] gauthierm@php.net
Getting this bug again in 5.4.6. Disabling APC makes it work properly.

PHP 5.4.6 x86_64
APC 3.1.10
libxml 2.7.6
 [2012-08-30 21:58 UTC] gauthierm@php.net
Please reopen.
 [2012-08-31 14:31 UTC] gauthierm@php.net
Ack! I didn't test APC 3.1.11. Please disregard. Anyone else still experiencing 
this bug should upgrade their APC version.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 18:01:55 2014 UTC