Cakephp - XML ToArray()
While debugging my timeline for delicious I noticied that CAKEPHP doesn't handle children correctly when making the XML feed to an array.
This was my feed from delicious. As you can see it has 1 parent of posts, with 3 children.
<posts user="dave_sherratt" update="2009-09-26T18:45:15Z" tag="" total="3"> <post href="http://www.alistapart.com/articles/beyond-goals-site-search-analytics-from-the-bottom-up/" hash="c08b0907341ef8327bbe7280f97012e4" description="A List Apart: Articles: Beyond Goals: Site Search Analytics from the Bottom Up" tag="" time="2009-09-26T18:45:14Z" extended="" meta="9e39487617202eb38423f0f3e3f993a3" /> <post href="http://www.pentacom.jp/soft/ex/font/edit.html" hash="69ab91b158496ccf9bcdac7b671529c4" description="FontEditor BitfontMaker" tag="" time="2009-09-25T18:15:34Z" extended="" meta="64350789d6bce415fcb1518f748393f9" /> <post href="http://www.techcrunch.com/2009/09/21/google-is-searching-for-beautiful-minds-but-so-far-no-m-i-t-students-have-broken-its-code/" hash="ea283d69a31c28d66c06ee99a3a7cc70" description="Google Is Searching For Beautiful Minds, But So Far No M.I.T. Students Have Broken Its Code." tag="tehcrunch, MIT, google" time="2009-09-21T17:04:57Z" extended="" meta="776c9fc9301235a3b2adee2847de88f0" /> </posts> <!-- fe07.api.del.ac4.yahoo.net uncompressed/chunked Sun Sep 27 09:16:00 PDT 2009 -->Instead of a creating an array with all 3 children, cakephp was continually overwriting the first array. This is a known bug and has quite an easy fix. Open cake/libs/xml.php and replace line 698 from $out[$key] = $value; with $out[$key][] = $value;

No Comments