Skip to content

[Bug]: "Trying to access array offset on null" on text 'null' value #80

@andrewpros

Description

@andrewpros

PHP Version

8.4.3

Version

2.0.0

Bug Description

Setting content with SetContent to text 'null' throws an error "Trying to access array offset on null" in vendor\\ueberdosis\\tiptap-php\\src\\Core\\Schema.php:70

Its because in https://github.com/ueberdosis/tiptap-php/blob/2.0.0/src/Editor.php#L45
getContentType is called https://github.com/ueberdosis/tiptap-php/blob/2.0.0/src/Editor.php#L96
and verifies the value using json_decode, but this accepts literal 'null' text as valid null

So in turn apply will get a null document https://github.com/ueberdosis/tiptap-php/blob/2.0.0/src/Core/Schema.php#L70

and throw

Expected Behavior

Be able to edit any text value, including 'null'

Additional Context (Optional)

I only found about this by chance using laravel filament RichEditor that is using this package under the hood.
The input data is external and imported to db, and there was some 'null' text in some of the fields.

Thats why there is also ready to test filament repo with this case as it was reported as filament issue here filamentphp/filament#18216 but closed due the issue being in the package

Dependency Updates

  • Yes, I've updated all my dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions