From cc1ec61b857cc793abab719c164496e8290291c1 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 9 Jul 2014 16:50:52 +0300 Subject: [PATCH 1/2] fix of issue #619 and other similar, error in JSLikeHTMLElement: node no longer exists. --- .../libraries/readability/Readability.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) mode change 100644 => 100755 inc/3rdparty/libraries/readability/Readability.php diff --git a/inc/3rdparty/libraries/readability/Readability.php b/inc/3rdparty/libraries/readability/Readability.php old mode 100644 new mode 100755 index d0f09d7..9e77dc5 --- 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 From c1aad6d5746ddb079e3b60d432212021c42c963b Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 9 Jul 2014 16:56:52 +0300 Subject: [PATCH 2/2] fix of issue #619 and other similar, error in JSLikeHTMLElement: node no longer exists. --- inc/3rdparty/libraries/readability/Readability.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/3rdparty/libraries/readability/Readability.php b/inc/3rdparty/libraries/readability/Readability.php index 9e77dc5..4fa3ba6 100755 --- a/inc/3rdparty/libraries/readability/Readability.php +++ b/inc/3rdparty/libraries/readability/Readability.php @@ -1142,9 +1142,9 @@ class Readability */ protected function reinitBody() { if (!isset($this->body->childNodes)) { - $this->body = $this->dom->createElement('body'); + $this->body = $this->dom->createElement('body'); + $this->body->innerHTML = $this->bodyCache; } - $this->body->innerHTML = $this->bodyCache; } }