kirby
kirby copied to clipboard
Add failsafe for permalinksToUrls method if uuid does not exist
Description
Example: A text block has an inline link to a page. If the linked page is deleted and the uuid does not exist anymore, the following error is displayed:
Block error: "DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated" in block type: "text"
Because in the permalinksToUrls
method, the $url
in this line is null
:
https://github.com/getkirby/kirby/blob/main/config/methods.php#L488
Your setup
Kirby Version
4.0.3
I just noticed the same issue outside of blocks. In this case the whole website went down because a page was deleted. I'd personally classify this as a bug instead of an enhancement.
To reproduce
- Add a writer field to your blueprint and use
permalinksToUrls()
in the frontend - Link a page
- Delete the page
Edit: I just saw the "This method is still experimental" disclaimer in the code, so I can understand where the "enhancement" is coming from. It would be great if this disclaimer could be added to the method docs.
I recently discussed this issue with @mrflix and he rightfully suggested it might help to talk about the expected behaviour:
The (link: ) tag deals with this in a very elegant way in my opinion. When debug mode is on, an exception is thrown, otherwise the error page's URL is used. I'd expect the permalinksToUrls()
method to work in a similar way.
In the meantime, as mentioned in my previous comment, I think the Kirby community would really appreciate a disclaimer in the docs. Not everyone looks at the source code and the method is there for a reason.
I'ld categorize this as a bug as well as it crashes page rendering in unexpected situations.
Is there any update on this?
Sorry that it took so long. This is definitely a bug. I just submitted a PR for it https://github.com/getkirby/kirby/pull/6313