Skip to content

Commit

Permalink
[BUGFIX] Fixes #242: Call to a member function count() on null
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsunday committed Aug 10, 2023
1 parent f3c7f27 commit 5aaef60
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/Backend/Preview/RteImagePreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down

0 comments on commit 5aaef60

Please sign in to comment.