Home » Configuration » Config » Bug #2071
unexpected results when reading XML config file and then writing it as PHPArra
Details
| Submitted | 2004-08-05 22:31 UTC |
|---|---|
| From | sthibaudeau at sqli dot com |
| Assigned | ryansking |
| Status | Closed |
| Package | Config |
| PHP Version | 4.3.4 |
| OS | windows 2000 |
| Roadmaps | (Not assigned) |
Comments
[2004-08-05 22:31 UTC] sthibaudeau at sqli dot com
Description:
------------
Unexpected results when parsing XML files and then writing them as PHPArray.
The files contain tags with the same names but not the same tags inside.
The problems occurs when one of the "twin" tag doesn't contain any other tag.
I was able to have the expected results by modifying Config_Container::getItemPosition() method.
I removed the test on the type and just let the test on the name.
I wasn't able to find out if that leads to bad side effects...
Correction made in file Container.php
Line 431 : $pchildren[$i]->type == $this->type (removed)
Reproduce code:
---------------
// Main PHP
$config = new Config;
$result = $config->parseConfig($xmlFile, 'XML');
$result = $config->writeConfig($cacheFile, 'PHPArray',array('name'=>'conf'));
// First test : XML input file
<?xml version="1.0"?>
<controller>
<action>something</action>
<action><label>test1</label></action>
<action><title>test2</title></action>
</controller>
// Second test : XML input file
<?xml version="1.0"?>
<controller>
<action></action>
<action><label>test1</label></action>
<action><title>test2</title></action>
</controller>
Expected result:
----------------
// First test : expected generated PHPArray
<?php
$conf['controller']['action'][0] = 'something';
$conf['controller']['action'][1]['label'] = 'test1';
$conf['controller']['action'][2]['title'] = 'test2';
?>
// Second test : expected generated PHPArray
<?php
$conf['controller']['action'][0] = '';
$conf['controller']['action'][1]['label'] = 'test1';
$conf['controller']['action'][2]['title'] = 'test2';
?>
Actual result:
--------------
// First test : generated PHPArray
<?php
$conf['controller']['action'][0] = 'something';
$conf['controller']['action'][0]['label'] = 'test1';
$conf['controller']['action'][1]['title'] = 'test2';
?>
// Second test : generated PHPArray
<?php
$conf['controller']['action'][0] = '';
$conf['controller']['action'][0]['label'] = 'test1';
$conf['controller']['action'][1]['title'] = 'test2';
?>
[2004-10-14 04:08 UTC] ryansking at mac dot com
I see that the fix you propose will fix this problem.
However, I need to be sure first that it won't cause more
problems.
[2004-12-09 17:44 UTC] ryansking at mac dot com
Thank you for taking the time to write to us, but this is not
a bug.
I believe this should be the expected behavior.