cms
cms copied to clipboard
Undefined property: stdClass::$attrs
Bug description
When I try to link to an internal entry, I get the following error:
Undefined property: stdClass::$attrs
I'm aware that I'm not using the latest version (due to issues), but I quickly upgraded to the latest 3.3.x to see if this fixes it, but the bug remains.
How to reproduce
Not sure. This is the entry content which causes the error (there are many similar entries). When I remove the contents, no error appears.
---
id: efda1f67-d394-444f-90f6-2a14617bdc90
blueprint: competition
title: 'Gewinne eines von drei Mikrodermabrasionsgeräten von PMD im Wert von je ca. 299 €!'
contents:
-
image_single: PMD_Gewinnspiel.jpg
type: image
enabled: true
-
text:
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Müde Haut, fahler Teint, große Poren: Jede Mama kennt zumindest eines dieser Probleme. Schließlich hinterlässt wenig Schlaf und der Hormonzirkus rund um Schwangerschaft und Geburt oft auch Spuren auf der Haut.'
-
type: heading
attrs:
level: 3
content:
-
type: text
marks:
-
type: bold
text: 'Wir möchten dir deswegen eine Freude bereiten und verlosen drei Mal das Mikrodermabrasionsgerät von PMD im Wert von je ca. 299€!'
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Mit dem Gerät kannst du dir eine Gesichtsbehandlung bequem nach Hause holen.'
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Der Aufsatz sorgt für weichere und glattere Haut, indem er abgestorbene Hautzellen entfernt, unter Vakuum absaugt und so den Revitalisierungsprozess der Haut anregt. '
-
type: paragraph
attrs:
class: null
content:
-
type: text
marks:
-
type: bold
text: 'Drei unterschiedliche Einstellungen ermöglichen eine individuelle Anpassung an deine Bedürfnisse:'
-
type: bullet_list
content:
-
type: list_item
content:
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Mindert sichtbar feine Linien, Falten und Hautverfärbungen'
-
type: list_item
content:
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Reduziert die Porengröße'
-
type: list_item
content:
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Erhöht die Feuchtigkeit der Haut'
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Ein klasse Beauty-Programm für lange Winterabende!'
-
type: heading
attrs:
level: 3
content:
-
type: text
marks:
-
type: bold
text: 'Gewinne hier eines von drei "Microderm Pro Elite" Dermabrasionsgeräten von PMD!'
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: 'Und was musst du tun, um zu gewinnen? Ganz einfach: Hinterlasse unter diesem Artikel einen Kommentar! Unter allen Kommentaren losen wir die Gewinnerinnen aus. Die Gewinnerinnen werden hier im Text bekannt gegeben und erhalten zusätzlich von uns eine Direktnachricht.*'
-
type: paragraph
attrs:
class: null
content:
-
type: text
marks:
-
type: bold
text: 'Viel Glück! '
type: text
enabled: true
-
image_single: PMD-Hautgerat.jpg
type: image
enabled: true
-
text:
-
type: paragraph
attrs:
class: null
content:
-
type: text
text: '*Hier findest du die '
-
type: text
marks:
-
type: link
attrs:
href: 'statamic://entry::1c359647-c503-4c52-85ee-2a4e1e6b8abb'
rel: null
target: _blank
title: null
text: 'Echte Mamas Club AGB'
-
type: text
text: ' und unsere '
-
type: text
marks:
-
type: link
attrs:
href: 'statamic://entry::1e2991d6-e561-49cb-aaf2-c03cc46d1f08'
rel: null
target: _blank
title: null
text: Datenschutzerklärung
-
type: text
text: .
type: text
enabled: true
tags:
- ssw18
- gewinnspiel
- ssw38
allow_comments: true
updated_by: 6bb75e4d-a280-4287-9b7d-c75782c654a8
updated_at: 1653901245
author: c545adea-400e-454e-883e-e0ffffa6f34b
valid_until: '2022-05-30'
preview_image: Gewinnspiel_pmd.jpg
kategorien:
- beauty
- pflege
starts_on: '2022-05-27'
---
A more simplified version of this works fine.
Logs
[2022-06-21 16:27:06] local.ERROR: Undefined property: stdClass::$attrs {"userId":"6bb75e4d-a280-4287-9b7d-c75782c654a8","exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$attrs at /Users/mooky/Code/echte-mamas/vendor/ueberdosis/prosemirror-to-html/src/Nodes/Image.php:20)
[stacktrace]
#0 /Users/mooky/Code/echte-mamas/vendor/ueberdosis/prosemirror-to-html/src/Nodes/Image.php(20): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Undefined prope...', '/Users/mooky/Co...', 20)
#1 /Users/mooky/Code/echte-mamas/vendor/ueberdosis/prosemirror-to-html/src/Renderer.php(88): ProseMirrorToHtml\\Nodes\\Image->tag()
#2 /Users/mooky/Code/echte-mamas/vendor/ueberdosis/prosemirror-to-html/src/Renderer.php(218): ProseMirrorToHtml\\Renderer->renderNode(Object(stdClass), NULL, Object(stdClass))
#3 /Users/mooky/Code/echte-mamas/vendor/statamic/cms/src/Fieldtypes/Bard.php(286): ProseMirrorToHtml\\Renderer->render(Array)
#4 /Users/mooky/Code/echte-mamas/vendor/statamic/cms/src/Fields/Field.php(293): Statamic\\Fieldtypes\\Bard->preProcessIndex(Array)
#5 /Users/mooky/Code/echte-mamas/vendor/statamic/cms/src/Http/Resources/CP/Entries/ListedEntry.php(66): Statamic\\Fields\\Field->preProcessIndex()
#6 /Users/mooky/Code/echte-mamas/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(742): Statamic\\Http\\Resources\\CP\\Entries\\ListedEntry->Statamic\\Http\\Resources\\CP\\Entries\\{closure}(Object(Statamic\\CP\\Column), 1)
#7 /Users/mooky/Code/echte-mamas/vendor/statamic/cms/src/Http/Resources/CP/Entries/ListedEntry.php(70): Illuminate\\Support\\Collection->mapWithKeys(Object(Closure))
#8 /Users/mooky/Code/echte-mamas/vendor/statamic/cms/src/Http/Resources/CP/Entries/ListedEntry.php(41): Statamic\\Http\\Resources\\CP\\Entries\\ListedEntry->values(Array)
#9 /Users/mooky/Code/echte-mamas/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/JsonResource.php(95): Statamic\\Http\\Resources\\CP\\Entries\\ListedEntry->toArray(Object(Illuminate\\Http\\Request))
#10 /Users/mooky/Code/echte-mamas/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/JsonResource.php(242): Illuminate\\Http\\Resources\\Json\\JsonResource->resolve(Object(Illuminate\\Http\\Request))
#11 /Users/mooky/Code/echte-mamas/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(888): Illuminate\\Http\\Resources\\Json\\JsonResource->jsonSerialize()
#12 [internal function]: Illuminate\\Support\\Collection->Illuminate\\Support\\Traits\\{closure}(Object(Statamic\\Http\\Resources\\CP\\Entries\\ListedEntry))
#13 /Users/mooky/Code/echte-mamas/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(896): array_map(Object(Closure), Array)
#14 [internal function]: Illuminate\\Support\\Collection->jsonSerialize()
#15 /Users/mooky/Code/echte-mamas/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php(87): json_encode(Array, 0)
Versions
Statamic 3.2.39 Pro Laravel 8.83.16 PHP 8.0.17 jacksleight/bard-paragraph-style 1.2.3 jonassiewertsen/statamic-livewire 2.9.0 octoper/statamic-blade-components 1.0.1 optimoapps/statamic-bard-text-align 1.0.2
Installation
Existing Laravel app
Antlers Parser
regex (default)
Additional details
No response
Hm. I now just changed contents: to contentss: and that fixes it?! What's wrong with contents as content handle?
I think part of the problem is the type: image nodes in the data, normally the structure of those looks like this:
-
type: image
attrs:
src: 'asset::assets::blinking-carot.gif'
alt: null
As the attrs key is missing in your data ProseMirror's Image extension is throwing the error. Are you using a custom Image extension in Bard? If so you might need to implement a custom extension in the augmentor/renderer as well.
@jacksleight But this also happens when there is not even an image inside the content. I'm also not using a custom image extension, all core stuff.
There are a bunch of different errors occurring, either Undefined property: stdClass::$attrs or htmlspecialchars(): Argument #1 ($string) must be of type string, array given. All coming from the prosemirror package.
But again, those errors are gone when instead of contents:, I use for example contentsx: (or anything else for that matter) for the Bard handle. Since this is an active, live project, I'd wish not to change this in every content file (~330 entries). 🤯
So after debugging a little more, the issues seems to be the following: the Bard handle is called contents. And as soon as within contents is a content instance, things fall apart. So this causes problems because of contents and content.
contents:
-
type: text
enabled: true
text:
-
type: paragraph
attrs:
class: null
content:
-
type: text
marks:
-
type: bold
text: 'something bla bla'
This works fine, as far as I can tell (replaced contents with contentsy):
contentsy:
-
type: text
enabled: true
text:
-
type: paragraph
attrs:
class: null
content:
-
type: text
marks:
-
type: bold
text: 'something bla bla '
That's super weird, no idea why changing the handle would have any effect. I just tested with a contents Bard field and it seems to work OK here.
But, this is also invalid ProseMirror data:
contents:
-
type: text
enabled: true
text:
-
type: paragraph
attrs:
class: null
content:
-
type: text
marks:
-
type: bold
text: 'something bla bla'
The text node type's text: key can only contain a string, which is why the text extension is throwing the htmlspecialchars(): Argument #1 ($string) must be of type string, array given error.
But, this is also invalid ProseMirror data
Mh, that's how Statamic generated it. ._.
Hey 👋
This issue has been inactive for a while now with no-one else running into the same issue. Since it was created, we've upgraded Bard to TipTap 2 in Statamic v4.4.
Therefore, I'm going to close this issue for now. If you're still experiencing this on the latest version of Statamic, leave a comment and we can re-open. Thanks!