Broken memoization of mentions in posts

I believe that there’s a minor typo on line 63 of post_analyzer.rb that is preventing memoization of mentions in posts:

https://github.com/discourse/discourse/blob/master/app/models/post_analyzer.rb#L63

In particular, the line is missing an ‘s’ and should be @raw_mentions = raw_mentions.

There is no functional impact of this – both post_spec and post_analyzer_spec pass with and without the correction. The net effect is simply that the mentions are recomputed each time the method is called.

As far as I can tell, there are no references to the singular raw_mention variable: egrep -irn 'raw_mention\b' . --include '*.rb' doesn’t come up with any results other than this single line. While I haven’t written any failing tests of the memoization behavior, I think that this is a pretty obvious bug.

5 Likes

Good catch, clearly looks like a typo to me given:

https://github.com/discourse/discourse/blob/master/app/models/post_analyzer.rb#L51

5 Likes

PR: https://github.com/discourse/discourse/pull/5172

4 Likes