v17development / flarum-blog

The Flarum Blog extension
https://discuss.flarum.org/d/25392-blog-adds-a-blog-section-to-your-community
MIT License
46 stars 20 forks source link

app.route.discussion assumes discussion.tags() is loaded #170

Open clarkwinkelmann opened 11 months ago

clarkwinkelmann commented 11 months ago

This issue is based on a report on Discuss, but can be seen by simple static reading of the code.

https://github.com/v17development/flarum-blog/blob/0d6cdf66bb6ad916197bcb7041f61c0c4d9d6c41/js/src/forum/utils/discussionRouting.js#L21

The code that generates a link to a discussion reads `discussion.tags().length without checking that the relationship returns an array first, leading in errors "trying to read property of undefined".

I doubt this situation happens often, if at all, without additional third party extension, but the actual problematic extensions should be irrelevant, the code cannot assume the method returns an array and this would show errors if Typescript typings were enforced.

Reference https://discuss.flarum.org/d/33733-typeerror-etags-is-not-a-function/3