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

Bug #13840 Attributes as column headers
Submitted: 2008-05-05 16:32 UTC
From: ice5nake Assigned: wiesemann
Status: Closed Package: Structures_DataGrid_DataSource_XML (version 0.2.0)
PHP Version: 5.2.5 OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 41 - 13 = ?

 
 [2008-05-05 16:32 UTC] ice5nake (Anthony Topper)
Description: ------------ I'd like to see the ability to have the test script below produce the column headings of acctname, timezone, campaign, adgroup, agStatus, currCode, imps, clicks, ctr, cpc, cpm, cost, pos. This was working when I had been using PHP4. Migrating to PHP5 broke this. Test script: --------------- <rows> <row acctname="x" timezone="(GMT-05:00) Eastern Time" campaign="y" adgroup="foo" agStatus="Enabled" currCode="USD" imps="20677" clicks="55" ctr="0.0026599603424094405" cpc="83090" cpm="221018" cost="4570000" pos="4.3982686076"/> <row acctname="x" timezone="(GMT-05:00) Eastern Time" campaign="d" adgroup="bar" agStatus="Enabled" currCode="USD" imps="974" clicks="4" ctr="0.004106776180698152" cpc="57500" cpm="236139" cost="230000" pos="5.3542094456"/> <row acctname="x" timezone="(GMT-05:00) Eastern Time" campaign="f" adgroup="oop" agStatus="Enabled" currCode="USD" imps="2393" clicks="9" ctr="0.0037609694943585457" cpc="43333" cpm="162975" cost="390000" pos="3.8821562892"/> </rows>

Comments

 [2008-05-05 17:27 UTC] olivierg (Olivier Guilyardi)
Yes, it does seem to work under PHP4, but there's something weird, for the "acctname" attribute, I'm getting a column named "attributesacctname". Is it what you had too? Were you using the "labels" option to translate this to proper column names?
 [2008-05-05 17:29 UTC] olivierg (Olivier Guilyardi)
(btw, please indicate your package version)
 [2008-05-05 17:32 UTC] olivierg (Olivier Guilyardi)
(fix package, sorry for the noise)
 [2008-05-05 17:48 UTC] ice5nake (Anthony Topper)
Fixed package field. Sorry. Under PHP4 I was getting "attributes" concatenated to the beginning to the beginning of the column name. I didn't use the label options. Hacked the ability to rename columns by walking through the DataSource _ar variable. That brings up another thought. Why is _ar private? Being able to rename column headers programmatically would be a nice at the DataSource level.
 [2008-05-05 18:05 UTC] olivierg (Olivier Guilyardi)
Thanks for your feedback. $_ar is private because it's internal mechanics. There's already a lot of BC breaking risks, we're not going to add one by letting anyone access this core data structure. If you want to automate renaming columns at the datasource level, you could overload getColumns() Regarding this bug, I'll keep the "attributes" prefix then, for BC. Trouble is under PHP5 we're using a completely different implementation, so that's not going to be straightforward. I've added a unit test that reproduces this bug: DataSourceXMLTest::testAttributeToColumn()
 [2008-05-05 18:06 UTC] olivierg (Olivier Guilyardi)
(this is a bug, changing type)
 [2008-05-05 18:40 UTC] olivierg (Olivier Guilyardi)
Mark, if you don't mind, I'm assigning this bug to you, since you're the one who refactored this driver. Please double check your changes, there are broken functionalities. In particular, you may want to take a look at : DataSourceXMLTest::testFieldAndLabelAttributes()
 [2008-05-09 15:38 UTC] ice5nake (Anthony Topper)
I var_dump'd $tmprow around line 200. $tmprow is a SimpleXMLElement object. Object Iteration on the SimpleXMLElement object doesn't appear to be working on my platform. I var_dump $value from inside the foreach ($tmprow as $key => $value) and get nothing. This means _processRowSimpleXML is getting passed an empty array in $row with the Test input data I originally posted under Test script. Hope this helps.
 [2008-05-09 19:26 UTC] ice5nake (Anthony Topper)
Patch added. Changed _parseXML. A one entrance one exit methodology would probably dry this function out some more. Don't need _processRowSimpleXML anymore. Hope this patch works for everyone. Is this the proper way to submit?
 [2008-05-10 12:01 UTC] olivierg (Olivier Guilyardi)
I'm afraid your _parseXML() method doesn't work for me. when running tests/DataSourceXMLTest.php, I get : Fatal error: Call to a member function attributes() on a non-object in /Users/olivier/dev/Structures_DataGrid/DataGrid/DataSource/XML.php on line 201 To learn how to submit a patch, please read: http://pear.php.net/manual/en/contributing.patches.php Thanks for your help
 [2008-05-14 19:08 UTC] wiesemann (Mark Wiesemann)
Sorry for the delay, I'll try to have a look on this issue within the next days.
 [2008-05-19 21:39 UTC] wiesemann (Mark Wiesemann)
Short update: - On PHP 5, all tests pass now (with code from CVS). - On PHP 4, the new test still fails. (This shouldn't be related to my refactoring, but I'll work on this anyway.) Tests of my changes with other XML files on PHP 5 are welcome.
 [2008-05-20 18:50 UTC] wiesemann (Mark Wiesemann)
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. --- There were several changes needed. The test suite works well with these changes, but there might be new problems with other XML data. Therefore, please test the changes.
 [2008-05-20 18:59 UTC] wiesemann (Mark Wiesemann)
Maybe I should add that I've renamed the 'content' value of the 'contentName' XML_Unserializer option to '_content' (which is BTW the default value) to avoid naming conflicts with tags that are named <content>.