From 8afd5adfcf6f7ec78eddb96b77efcd316a0a0293 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 22 Mar 2015 16:06:19 +0100 Subject: fix scrutinizer warnings --- articleenhancer/xpatharticleenhancer.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'articleenhancer/xpatharticleenhancer.php') diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 67fbf78d2..61bf230a0 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -25,7 +25,6 @@ use OCA\News\Db\Item; class XPathArticleEnhancer implements ArticleEnhancer { - private $maximumTimeout; private $clientFactory; private $regexXPathPair; @@ -72,7 +71,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { } $dom = new DOMDocument(); - @$dom->loadHTML($body); + $isOk = @$dom->loadHTML($body); $xpath = new DOMXpath($dom); $xpathResult = $xpath->evaluate($search); @@ -90,7 +89,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { $xpathResult, $item->getUrl() ); - if($xpathResult) { + if($isOk && $xpathResult !== false && $xpathResult !== '') { $item->setBody($xpathResult); } } @@ -122,7 +121,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { $dom->preserveWhiteSpace = false; if($xmlString === '') { - return false; + return ''; } $xmlString = '
' . $xmlString . '
'; @@ -130,7 +129,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { LIBXML_HTML_NODEFDTD); if(!$isOk) { - return false; + return ''; } foreach (['href', 'src'] as $attribute) { -- cgit v1.2.3