Avoid childnode becoming null to generate a warning

This commit is contained in:
Jeremy Benoist
2017-01-10 10:58:12 +01:00
parent ade850534c
commit ff754b80bd
3 changed files with 155 additions and 0 deletions
+5
View File
@@ -758,6 +758,11 @@ class Readability implements LoggerAwareInterface
for ($i = 0, $il = $node->childNodes->length; $i < $il; ++$i) {
$childNode = $node->childNodes->item($i);
// it looks like sometimes the loop is going too far and we are retrieving a non-existant child
if (null === $childNode) {
continue;
}
// executable tags (<?php or <?xml) warning
if (is_object($childNode) && get_class($childNode) === 'DOMProcessingInstruction') {
$childNode->parentNode->removeChild($childNode);