tiptap-php
tiptap-php copied to clipboard
Array to string conversion
Hi there,
Silly question but when I trying to get JSON from the following HTML, it throws Array to string conversion in ../vendor/ueberdosis/tiptap-php/src/Core/DOMParser.php on line 144.
<p><iframe frameborder="0" height="385" src="https://www.youtube.com/embed/xxx" width="590"></iframe></p>
<p><iframe frameborder="0" height="385" src="https://www.youtube.com/embed/yyy" width="590"></iframe></p>
Have you been able to find out what was the reason of that? Have you got it fixed?
ive also started having this issue, no real leads on whats causing it, i was migrating away from the deprecated tiptap parser but i definitely cant unless i get more info on how this is occuring
Same issue
I'm also experiencing this issue.
It seems to be related to the this multidimensional array check failing to detect empty nested arrays as described here. Since the check fails, the array_diff that follows throws an exception as described here.
A better (although possibly slower) approach would be to check for a multidimensional array doing something like this:
private function isMultiArray( $arr ) {
rsort( $arr );
return isset( $arr[0] ) && is_array( $arr[0] );
}
private function mergeSimilarNodes($nodes)
{
$result = [];
array_reduce($nodes, function ($carry, $node) use (&$result) {
// Ignore multidimensional arrays
if ($this->isMultiArray($node) || $this->isMultiArray($carry))
{
$result[] = $node;
return $node;
}
...
}
}
I tested this locally and it seemed to work fine. I'll see about getting a pull request put together within the next few days.
Very weird, happens to me on production but not locally same php version tho. For me this was caused by my old editor wrapping img tags in an additional p tag.
PHP: 8.2.5
I just encountered this while attempting to import content from WordPress - it wraps everything in p tags.
Submitted a PR with a failing test, so hopefully it gets merged soon 🤞
I'm also getting this error while parsing html, no idea what's triggering it.
On version 1.3.0
@enkay I'm now quite certain this is caused by the p tag surrounding the image.