#6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601] --------------------------+------------------------------------------------- Reporter: olafnorge | Type: Bug Status: new | Priority: Medium Milestone: 1.2.x.x | Component: Core Libs Version: 1.2 Final | Severity: Trivial Keywords: | Php_version: PHP 5 Cake_version: | --------------------------+------------------------------------------------- I'm using the lastest stable release (1.2.2.8120) from your website.
I want to create a xml from an array. Therefore I create a new object of the XML-class with a custom root-element. {{{ public static function arrayToXml($xml, $options = array()) { App::import('Core', 'Xml'); $xml = new Xml($xml, array('root' => 'rootnode')); $xml = $xml->compose(true); return $xml; } }}} If I execute the code the PHP-Parser prints out a notice: {{{ Trying to get property of non-object [CORE/cake/libs/xml.php, line 601] }}} To fix this, I added an additional clause to the if statement at line 601. Before: {{{ if ($parent->name === '#document' && count($parent->namespaces) > 0) { foreach ($parent->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; } } }}} After: {{{ if (is_object($parent) && $parent->name === '#document' && count($parent->namespaces) > 0) { foreach ($parent->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; } } }}} It would be great, if you can add that to the next release or svn. -- Ticket URL: <https://trac.cakephp.org/ticket/6294> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---