Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if EntryComment is defined and not null #1129

Merged
merged 6 commits into from
Sep 13, 2024

Conversation

melroy89
Copy link
Member

@melroy89 melroy89 commented Sep 13, 2024

EntryComment can be null after all during the __invoke. So comment can still be null. Let's update Twig to check for defined and not null, to avoid template errors..


100% repeatable now. Eg. https://kbin.melroy.org/m/[email protected]/t/457088/The-entire-staff-of-beloved-game-publisher-Annapurna-Interactive-has/comment (so without any comment ID at the end provided in the URL)

Will give:

{"message":"Uncaught PHP Exception Twig\\Error\\RuntimeError: \"Error rendering \"entry_comment\" component: Expected argument of type \"App\\Entity\\EntryComment\", \"null\" given at property path \"comment\".\" at view.html.twig line 49","context":{"exception":{"class":"Twig\\Error\\RuntimeError","message":"Error rendering \"entry_comment\" component: Expected argument of type \"App\\Entity\\EntryComment\", \"null\" given at property path \"comment\".","code":0,"file":"/var/www/kbin.melroy.org/html/templates/entry/comment/view.html.twig:49","previous": ... }

With error:

image


However, with this patch. You will no longer get this 500 error ⛱️ . And show an error instead:

image

@melroy89 melroy89 added bug Something isn't working frontend Visual issues, improvements, bugs or other aspects relating mostly to the front end labels Sep 13, 2024
@melroy89 melroy89 added this to the v1.7.2 milestone Sep 13, 2024
@melroy89
Copy link
Member Author

Also added an error with a back button in case of an empty/null entry comment...

@melroy89 melroy89 enabled auto-merge (squash) September 13, 2024 16:46
@melroy89
Copy link
Member Author

Tested and works as expected now.

@melroy89 melroy89 merged commit 89c1334 into main Sep 13, 2024
7 checks passed
@melroy89 melroy89 deleted the check_entry_comment_defined_and_not_null branch September 13, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Visual issues, improvements, bugs or other aspects relating mostly to the front end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants