Re: [CakePHP : The Rapid Development Framework for PHP] #6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]

2009-04-16 Thread CakePHP : The Rapid Development Framework for PHP
#6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]
--+-
Reporter:  olafnorge  | Owner:  davidpersson
Type:  Bug|Status:  new 
Priority:  Medium | Milestone:  1.2.x.x 
   Component:  Core Libs  |   Version:  1.2 Final   
Severity:  Trivial|Resolution:  
Keywords: |   Php_version:  PHP 5   
Cake_version: |  
--+-
Changes (by davidpersson):

  * owner:  => davidpersson
  * status:  reopened => new

-- 
Ticket URL: 
CakePHP : The Rapid Development Framework for PHP 
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
-~--~~~~--~~--~--~---



Re: [CakePHP : The Rapid Development Framework for PHP] #6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]

2009-04-16 Thread CakePHP : The Rapid Development Framework for PHP
#6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]
--+-
Reporter:  olafnorge  | Owner:   
Type:  Bug|Status:  reopened 
Priority:  Medium | Milestone:  1.2.x.x  
   Component:  Core Libs  |   Version:  1.2 Final
Severity:  Trivial|Resolution:   
Keywords: |   Php_version:  PHP 5
Cake_version: |  
--+-
Changes (by olafnorge):

  * status:  closed => reopened
  * resolution:  needmoreinfo =>

Comment:

 This is an example array for what I'm trying to create xml.

 {{{
 $xml = array(
 array('node' => array(
 'tag1' => 'value1',
 'tag2' => 'value2',
 'tag3' => 'value3',
 'tag4' => '',
 'tag5' => 35,
 ),
 ),
 array('node' => array(
 'tag1' => 'value1',
 'tag2' => 'value2',
 'tag3' => 'value3',
 'tag4' => array(
 'subtag4_1' => 'subvalue4_1',
 ),
 'tag5' => 2,
 ),
 ),
 );
 }}}

 Same array as a dump

 {{{
 Array
 (
 [0] => Array
 (
 [node] => Array
 (
 [tag1] => value1
 [tag2] => value2
 [tag3] => value3
 [tag4] =>
 [tag5] => 35
 )

 )

 [1] => Array
 (
 [node] => Array
 (
 [tag1] => value1
 [tag2] => value2
 [tag3] => value3
 [tag4] => Array
 (
 [subtag4_1] => subvalue4_1
 )

 [tag5] => 2
 )

 )

 )
 }}}

 I call the construct of the XML-class with the $xml-array as the first
 parameter and the second parameter is an array which tells the construct
 what the name of the root-element should be (as you can see at my
 description above).

 The xml will be created correctly but there's always a notice at line 601
 as you also can see at my description.

 Here is some more code of the xml-library.

 {{{
 587 if ($tag) {
 588 if ($options['whitespace']) {
 589 $d .= str_repeat("\t", $depth);
 590 }
 591
 592 $d .= '<' . $this->name();
 593 if (count($this->namespaces) > 0) {
 594 foreach ($this->namespaces as $key => $val) {
 595 $val = str_replace('"', '\"', $val);
 596 $d .= ' xmlns:' . $key . '="' . $val . '"';
 597 }
 598 }
 599
 600 $parent =& $this->parent();
 601 if ($parent->name === '#document' &&
 count($parent->namespaces) > 0) {
 602 foreach ($parent->namespaces as $key => $val) {
 603 $val = str_replace('"', '\"', $val);
 604 $d .= ' xmlns:' . $key . '="' . $val . '"';
 605 }
 606 }
 607
 608 if (is_array($this->attributes) &&
 count($this->attributes) > 0) {
 609 foreach ($this->attributes as $key => $val) {
 610 $d .= ' ' . $key . '="' .
 htmlspecialchars($val, ENT_QUOTES, Configure::read('App.encoding')) . '"';
 611 }
 612 }
 613 }
 }}}

 Have a look at the lines 600 and 601. The variable ''$parent'' gets the
 reference of ''$this->parent()'' assigned. But if there is no such parent
 then no reference could be assigned. And if no reference was assigned
 there could not be any object. To avoid a call on non existing object I
 added the is_object-question to the if-clause. What should I test? Either
 there is an object then I can call it's attributes or there isn't an
 object and I can't call any function or attributes.

 I don't think there's any need for a testcase. I think the bug and the fix
 is pretty straight forward.

-- 
Ticket URL: 
CakePHP : The Rapid Development Framework for PHP 
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.
--~--~-~--~~~---~--~---

Re: [CakePHP : The Rapid Development Framework for PHP] #6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]

2009-04-15 Thread CakePHP : The Rapid Development Framework for PHP
#6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]
--+-
Reporter:  olafnorge  | Owner:  
Type:  Bug|Status:  closed  
Priority:  Medium | Milestone:  1.2.x.x 
   Component:  Core Libs  |   Version:  1.2 Final   
Severity:  Trivial|Resolution:  needmoreinfo
Keywords: |   Php_version:  PHP 5   
Cake_version: |  
--+-
Changes (by nate):

  * status:  new => closed
  * resolution:  => needmoreinfo

Comment:

 How do we know if your fix is any good?  Can you attach a test case, or at
 least a dump of the array you're having a problem with?  Please re-open
 with more data.

-- 
Ticket URL: 
CakePHP : The Rapid Development Framework for PHP 
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
-~--~~~~--~~--~--~---



[CakePHP : The Rapid Development Framework for PHP] #6294: Trying to get property of non-object [CORE/cake/libs/xml.php, line 601]

2009-04-15 Thread CakePHP : The Rapid Development Framework for PHP
#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: 
CakePHP : The Rapid Development Framework for PHP 
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
-~--~~~~--~~--~--~---