From 5aaef6022cb9c6f1fe230182ba63f47a7406907e Mon Sep 17 00:00:00 2001 From: Rico Sonntag Date: Thu, 10 Aug 2023 12:14:36 +0000 Subject: [PATCH] [BUGFIX] Fixes #242: Call to a member function count() on null --- Classes/Backend/Preview/RteImagePreviewRenderer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Classes/Backend/Preview/RteImagePreviewRenderer.php b/Classes/Backend/Preview/RteImagePreviewRenderer.php index 262470f..14a045e 100644 --- a/Classes/Backend/Preview/RteImagePreviewRenderer.php +++ b/Classes/Backend/Preview/RteImagePreviewRenderer.php @@ -110,7 +110,7 @@ private function walk(DOMNode $node, int $maxLength): array if ($this->reachedLimit) { $this->toRemove[] = $node; } else { - // Only text nodes should have text, so do the splitting here + // Only text nodes should have a text, so do the splitting here if (($node instanceof DOMText) && ($node->nodeValue !== null)) { $this->totalLength += $nodeLen = mb_strlen($node->nodeValue); @@ -126,7 +126,10 @@ private function walk(DOMNode $node, int $maxLength): array } // If node has children, walk its child elements - if ($node->childNodes->count() > 0) { + if ( + ($node->childNodes !== null) + && ($node->childNodes->count() > 0) + ) { foreach ($node->childNodes as $child) { $this->walk($child, $maxLength); }