From cc1ec61b857cc793abab719c164496e8290291c1 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 9 Jul 2014 16:50:52 +0300 Subject: fix of issue #619 and other similar, error in JSLikeHTMLElement: node no longer exists. --- inc/3rdparty/libraries/readability/Readability.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) mode change 100644 => 100755 inc/3rdparty/libraries/readability/Readability.php (limited to 'inc/3rdparty/libraries/readability') diff --git a/inc/3rdparty/libraries/readability/Readability.php b/inc/3rdparty/libraries/readability/Readability.php old mode 100644 new mode 100755 index d0f09d74..9e77dc55 --- a/inc/3rdparty/libraries/readability/Readability.php +++ b/inc/3rdparty/libraries/readability/Readability.php @@ -679,6 +679,7 @@ class Readability } else { $topCandidate->innerHTML = $page->documentElement->innerHTML; $page->documentElement->innerHTML = ''; + $this->reinitBody(); $page->documentElement->appendChild($topCandidate); } } else { @@ -794,8 +795,7 @@ class Readability { // TODO: find out why element disappears sometimes, e.g. for this URL http://www.businessinsider.com/6-hedge-fund-etfs-for-average-investors-2011-7 // in the meantime, we check and create an empty element if it's not there. - if (!isset($this->body->childNodes)) $this->body = $this->dom->createElement('body'); - $this->body->innerHTML = $this->bodyCache; + $this->reinitBody(); if ($this->flagIsActive(self::FLAG_STRIP_UNLIKELYS)) { $this->removeFlag(self::FLAG_STRIP_UNLIKELYS); @@ -1134,5 +1134,18 @@ class Readability public function removeFlag($flag) { $this->flags = $this->flags & ~$flag; } + + /** + * Will recreate previously deleted body property + * + * @return void + */ + protected function reinitBody() { + if (!isset($this->body->childNodes)) { + $this->body = $this->dom->createElement('body'); + } + $this->body->innerHTML = $this->bodyCache; + } + } ?> \ No newline at end of file -- cgit v1.2.3