Merge pull request #7251 from Wikia/DAT-2824

DAT-2824 Fix warnings when node has no child nodes
This commit is contained in:
Rodrigo Molinero Gomez 2015-05-21 10:53:55 +02:00
commit cbaa447894

View file

@ -28,8 +28,12 @@ class SimpleXmlUtil {
public function getInnerXML( $node ) {
$innerXML = '';
if ( $node instanceof \SimpleXMLElement ) {
foreach ( dom_import_simplexml( $node )->childNodes as $child ) {
$innerXML .= $child->ownerDocument->saveXML( $child );
$domElement = dom_import_simplexml( $node );
if ( ( $domElement instanceof \DOMElement ) && ( $domElement->hasChildNodes() ) ) {
foreach ( $domElement->childNodes as $child ) {
$innerXML .= $child->ownerDocument->saveXML( $child );
}
}
}
return $innerXML;