DAT-2875 check for empty nodes updated

This commit is contained in:
idradm 2015-06-16 13:45:27 +02:00
parent 6ab4e92781
commit 87e83502b8
2 changed files with 6 additions and 1 deletions

View file

@ -156,6 +156,7 @@ class PortableInfoboxParserTagController extends WikiaController {
//make sure no whitespaces, prevents side effects
return self::INFOBOX_LAYOUT_PREFIX . $layoutName;
}
return self::INFOBOX_LAYOUT_PREFIX . self::DEFAULT_LAYOUT_NAME;
}

View file

@ -15,6 +15,7 @@ class SimpleXmlUtil {
if ( is_null( self::$instance ) ) {
self::$instance = new self;
}
return self::$instance;
}
@ -23,11 +24,13 @@ class SimpleXmlUtil {
* Will return empty string for a non-node argument
*
* @param $node
*
* @return string
*/
public function getInnerXML( $node ) {
$innerXML = '';
if ( $node instanceof \SimpleXMLElement ) {
// check for empty nodes, strlen used for "0" strings match
if ( $node instanceof \SimpleXMLElement && ( strlen( (string)$node ) || $node->count() ) ) {
$domElement = dom_import_simplexml( $node );
if ( ( $domElement instanceof \DOMElement ) && ( $domElement->hasChildNodes() ) ) {
@ -36,6 +39,7 @@ class SimpleXmlUtil {
}
}
}
return $innerXML;
}
}