Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLElement: passing XMLElement Object as $value fails #1000

Closed
iwyg opened this issue Feb 3, 2012 · 1 comment
Closed

XMLElement: passing XMLElement Object as $value fails #1000

iwyg opened this issue Feb 3, 2012 · 1 comment

Comments

@iwyg
Copy link
Contributor

iwyg commented Feb 3, 2012

When creating an new instance of XMLElement and passing another XMLElement (instead of a string ) as $value I get this error (public generate):

strlen() expects parameter 1 to be string, object given
/Users/malcolm/Sites/symdev/symphony/lib/toolkit/class.xmlelement.php line 592

587             }
588         }
589
590         $numberOfchildren = $this->getNumberOfChildren();
591
592         if($numberOfchildren > 0 || strlen($this->_value) != 0 || !$this->_selfclosing){
593
594             $result .= '>';
595
596

I did a quick test in evaluating that $this->_value is a string before getting its strlen. This would remove the error but the child element never gets appended to its parent Element.
Can you confirm this?

@brendo
Copy link
Member

brendo commented Feb 3, 2012

Yes I can confirm this bug, the documentation incorrectly (or correctly because I'd expect XMLElement to work this way) states that it can accept the $value as either a string or an XMLElement object. It's not the case, as you've documented.

Thanks for reporting.

For a immediate solution you can use new XMLElement('your-node-name', $value->generate()); which will create a string.

@brendo brendo closed this as completed in 13e8ea4 Mar 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants