Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Bug #7652 wrong xml to phparray convert
Submitted: 2006-05-17 19:11 UTC
From: farell Assigned: aashley
Status: Closed Package: Config (version 1.10.6)
PHP Version: 4.4.2 OS: windows xp
Roadmaps: (Not assigned)    
Subscription  


 [2006-05-17 19:11 UTC] farell (Laurent Laville)
Description: ------------ I've found this bug while i've implemented a config solution for my PEAR_PackageFileManager frontend. When you have xml structures with multiple same type of items (tag1), like that: <root> <tag1 attrib="val" /> <tag1 attrib="val2" > <tag2>hello world </tag2> </tag1> <tag1 attrib="val23" /> </root> When you try to convert to phparray, indices of php array should be 0,1,2 but indice sequence is lost. Here is an xml structure i've try to convert with test script below: <page> is eq to <tag1> in this example <?xml version="1.0" encoding="UTF-8"?> <pages> <page class="PackagePage" id="page1" name="Package"/> <page class="ReleasePage" id="page2" name="Release"/> <page class="MaintainersPage" id="page3" name="Maintainers"> <drop class="MaintainersPageAction"/> <add class="MaintainersPageAction"/> <edit class="MaintainersPageAction"/> <save class="MaintainersPageAction"/> <cancel class="MaintainersPageAction"/> </page> <page class="DependenciesPage" id="page4" name="Dependencies"> <drop class="DependenciesPageAction"/> <add class="DependenciesPageAction"/> <edit class="DependenciesPageAction"/> <save class="DependenciesPageAction"/> <cancel class="DependenciesPageAction"/> </page> <page class="ReplacementsPage" id="page5" name="Replacements"> <list class="ReplacementsPageAction"/> <ignore class="ReplacementsPageAction"/> <edit class="ReplacementsPageAction"/> <remove class="ReplacementsPageAction"/> <new class="ReplacementsPageAction"/> <save class="ReplacementsPageAction"/> <cancel class="ReplacementsPageAction"/> </page> <page class="RolesPage" id="page6" name="Roles"> <drop class="RolesPageAction"/> <edit class="RolesPageAction"/> <save class="RolesPageAction"/> <cancel class="RolesPageAction"/> </page> <page class="ExceptionsPage" id="page7" name="Exceptions"> <edit class="ExceptionsPageAction"/> <remove class="ExceptionsPageAction"/> <save class="ExceptionsPageAction"/> <cancel class="ExceptionsPageAction"/> </page> <page class="PreviewPage" id="page8" name="Preview"/> <page class="ErrorsPage" id="page0" name="Errors"/> </pages> Once convertion is finished we should have $conf['pages']['page'] an array(9) from 0 to 8 and we have only an array(5) from 0 to 4 Hope my explains are enough clean Laurent Test script: --------------- <?php require_once 'Config.php'; $_conf = new Config(); $source = 'xhtml_conf.xml'; $type = 'xml'; $options = array(); $res =& $_conf->parseConfig($source, $type, $options); $root =& $_conf->getRoot(); echo '<pre>'. $root->toString('phparray') .'</pre>'; ?> Expected result: ---------------- $conf['pages']['page'][0]['#'] = ''; $conf['pages']['page'][0]['@']['class'] = 'PackagePage'; $conf['pages']['page'][0]['@']['id'] = 'page1'; $conf['pages']['page'][0]['@']['name'] = 'Package'; $conf['pages']['page'][1]['#'] = ''; $conf['pages']['page'][1]['@']['class'] = 'ReleasePage'; $conf['pages']['page'][1]['@']['id'] = 'page2'; $conf['pages']['page'][1]['@']['name'] = 'Release'; $conf['pages']['page'][2]['@']['class'] = 'MaintainersPage'; $conf['pages']['page'][2]['@']['id'] = 'page3'; $conf['pages']['page'][2]['@']['name'] = 'Maintainers'; $conf['pages']['page'][2]['drop']['#'] = ''; $conf['pages']['page'][2]['drop']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][2]['add']['#'] = ''; $conf['pages']['page'][2]['add']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][2]['edit']['#'] = ''; $conf['pages']['page'][2]['edit']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][2]['save']['#'] = ''; $conf['pages']['page'][2]['save']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][2]['cancel']['#'] = ''; $conf['pages']['page'][2]['cancel']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][3]['@']['class'] = 'DependenciesPage'; $conf['pages']['page'][3]['@']['id'] = 'page4'; $conf['pages']['page'][3]['@']['name'] = 'Dependencies'; $conf['pages']['page'][3]['drop']['#'] = ''; $conf['pages']['page'][3]['drop']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][3]['add']['#'] = ''; $conf['pages']['page'][3]['add']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][3]['edit']['#'] = ''; $conf['pages']['page'][3]['edit']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][3]['save']['#'] = ''; $conf['pages']['page'][3]['save']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][3]['cancel']['#'] = ''; $conf['pages']['page'][3]['cancel']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][4]['@']['class'] = 'ReplacementsPage'; $conf['pages']['page'][4]['@']['id'] = 'page5'; $conf['pages']['page'][4]['@']['name'] = 'Replacements'; $conf['pages']['page'][4]['list']['#'] = ''; $conf['pages']['page'][4]['list']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][4]['ignore']['#'] = ''; $conf['pages']['page'][4]['ignore']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][4]['edit']['#'] = ''; $conf['pages']['page'][4]['edit']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][4]['remove']['#'] = ''; $conf['pages']['page'][4]['remove']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][4]['new']['#'] = ''; $conf['pages']['page'][4]['new']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][4]['save']['#'] = ''; $conf['pages']['page'][4]['save']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][4]['cancel']['#'] = ''; $conf['pages']['page'][4]['cancel']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][5]['@']['class'] = 'RolesPage'; $conf['pages']['page'][5]['@']['id'] = 'page6'; $conf['pages']['page'][5]['@']['name'] = 'Roles'; $conf['pages']['page'][5]['drop']['#'] = ''; $conf['pages']['page'][5]['drop']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][5]['edit']['#'] = ''; $conf['pages']['page'][5]['edit']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][5]['save']['#'] = ''; $conf['pages']['page'][5]['save']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][5]['cancel']['#'] = ''; $conf['pages']['page'][5]['cancel']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][6]['@']['class'] = 'ExceptionsPage'; $conf['pages']['page'][6]['@']['id'] = 'page7'; $conf['pages']['page'][6]['@']['name'] = 'Exceptions'; $conf['pages']['page'][6]['edit']['#'] = ''; $conf['pages']['page'][6]['edit']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][6]['remove']['#'] = ''; $conf['pages']['page'][6]['remove']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][6]['save']['#'] = ''; $conf['pages']['page'][6]['save']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][6]['cancel']['#'] = ''; $conf['pages']['page'][6]['cancel']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][7]['#'] = ''; $conf['pages']['page'][7]['@']['class'] = 'PreviewPage'; $conf['pages']['page'][7]['@']['id'] = 'page8'; $conf['pages']['page'][7]['@']['name'] = 'Preview'; $conf['pages']['page'][8]['#'] = ''; $conf['pages']['page'][8]['@']['class'] = 'ErrorsPage'; $conf['pages']['page'][8]['@']['id'] = 'page0'; $conf['pages']['page'][8]['@']['name'] = 'Errors'; Actual result: -------------- $conf['pages']['page'][0]['#'] = ''; $conf['pages']['page'][0]['@']['class'] = 'PackagePage'; $conf['pages']['page'][0]['@']['id'] = 'page1'; $conf['pages']['page'][0]['@']['name'] = 'Package'; $conf['pages']['page'][1]['#'] = ''; $conf['pages']['page'][1]['@']['class'] = 'ReleasePage'; $conf['pages']['page'][1]['@']['id'] = 'page2'; $conf['pages']['page'][1]['@']['name'] = 'Release'; $conf['pages']['page'][0]['@']['class'] = 'MaintainersPage'; $conf['pages']['page'][0]['@']['id'] = 'page3'; $conf['pages']['page'][0]['@']['name'] = 'Maintainers'; $conf['pages']['page'][0]['drop']['#'] = ''; $conf['pages']['page'][0]['drop']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][0]['add']['#'] = ''; $conf['pages']['page'][0]['add']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][0]['edit']['#'] = ''; $conf['pages']['page'][0]['edit']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][0]['save']['#'] = ''; $conf['pages']['page'][0]['save']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][0]['cancel']['#'] = ''; $conf['pages']['page'][0]['cancel']['@']['class'] = 'MaintainersPageAction'; $conf['pages']['page'][1]['@']['class'] = 'DependenciesPage'; $conf['pages']['page'][1]['@']['id'] = 'page4'; $conf['pages']['page'][1]['@']['name'] = 'Dependencies'; $conf['pages']['page'][1]['drop']['#'] = ''; $conf['pages']['page'][1]['drop']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][1]['add']['#'] = ''; $conf['pages']['page'][1]['add']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][1]['edit']['#'] = ''; $conf['pages']['page'][1]['edit']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][1]['save']['#'] = ''; $conf['pages']['page'][1]['save']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][1]['cancel']['#'] = ''; $conf['pages']['page'][1]['cancel']['@']['class'] = 'DependenciesPageAction'; $conf['pages']['page'][2]['@']['class'] = 'ReplacementsPage'; $conf['pages']['page'][2]['@']['id'] = 'page5'; $conf['pages']['page'][2]['@']['name'] = 'Replacements'; $conf['pages']['page'][2]['list']['#'] = ''; $conf['pages']['page'][2]['list']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][2]['ignore']['#'] = ''; $conf['pages']['page'][2]['ignore']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][2]['edit']['#'] = ''; $conf['pages']['page'][2]['edit']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][2]['remove']['#'] = ''; $conf['pages']['page'][2]['remove']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][2]['new']['#'] = ''; $conf['pages']['page'][2]['new']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][2]['save']['#'] = ''; $conf['pages']['page'][2]['save']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][2]['cancel']['#'] = ''; $conf['pages']['page'][2]['cancel']['@']['class'] = 'ReplacementsPageAction'; $conf['pages']['page'][3]['@']['class'] = 'RolesPage'; $conf['pages']['page'][3]['@']['id'] = 'page6'; $conf['pages']['page'][3]['@']['name'] = 'Roles'; $conf['pages']['page'][3]['drop']['#'] = ''; $conf['pages']['page'][3]['drop']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][3]['edit']['#'] = ''; $conf['pages']['page'][3]['edit']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][3]['save']['#'] = ''; $conf['pages']['page'][3]['save']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][3]['cancel']['#'] = ''; $conf['pages']['page'][3]['cancel']['@']['class'] = 'RolesPageAction'; $conf['pages']['page'][4]['@']['class'] = 'ExceptionsPage'; $conf['pages']['page'][4]['@']['id'] = 'page7'; $conf['pages']['page'][4]['@']['name'] = 'Exceptions'; $conf['pages']['page'][4]['edit']['#'] = ''; $conf['pages']['page'][4]['edit']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][4]['remove']['#'] = ''; $conf['pages']['page'][4]['remove']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][4]['save']['#'] = ''; $conf['pages']['page'][4]['save']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][4]['cancel']['#'] = ''; $conf['pages']['page'][4]['cancel']['@']['class'] = 'ExceptionsPageAction'; $conf['pages']['page'][2]['#'] = ''; $conf['pages']['page'][2]['@']['class'] = 'PreviewPage'; $conf['pages']['page'][2]['@']['id'] = 'page8'; $conf['pages']['page'][2]['@']['name'] = 'Preview'; $conf['pages']['page'][3]['#'] = ''; $conf['pages']['page'][3]['@']['class'] = 'ErrorsPage'; $conf['pages']['page'][3]['@']['id'] = 'page0'; $conf['pages']['page'][3]['@']['name'] = 'Errors';

Comments

 [2006-05-30 06:38 UTC] aashley at php dot net (Adam Ashley)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.