# Broken memoization of mentions in posts

**URL:** https://meta.discourse.org/t/broken-memoization-of-mentions-in-posts/69671
**Category:** Bug
**Created:** [2017年九月8日 22:51 UTC](https://meta.discourse.org/t/broken-memoization-of-mentions-in-posts/69671 "2017-09-08T22:51:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Darren\_Lee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darren_lee/32/120711_2.png) [@Darren\_Lee](https://meta.discourse.org/u/Darren_Lee)
#### Post date: [2017年九月8日 22:51 UTC](https://meta.discourse.org/t/broken-memoization-of-mentions-in-posts/69671/1 "2017-09-08T22:51:05Z")

</div>

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/main/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.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2017年九月8日 23:04 UTC](https://meta.discourse.org/t/broken-memoization-of-mentions-in-posts/69671/2 "2017-09-08T23:04:16Z")

</div>

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

> <https://github.com/discourse/discourse/blob/main/app/models/post_analyzer.rb#L51>

---

<div class="post-metadata">

### Author: ![Darren\_Lee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darren_lee/32/120711_2.png) [@Darren\_Lee](https://meta.discourse.org/u/Darren_Lee)
#### Post date: [2017年九月11日 18:00 UTC](https://meta.discourse.org/t/broken-memoization-of-mentions-in-posts/69671/3 "2017-09-11T18:00:13Z")

</div>

PR: [FIX: memoization in PostAnalyzer.raw\_mentions by balshor · Pull Request #5172 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5172)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017年九月11日 21:28 UTC](https://meta.discourse.org/t/broken-memoization-of-mentions-in-posts/69671/4 "2017-09-11T21:28:52Z")

</div>


