Some imported avatar thumbnails are broken


I’m running into similar issues to the original posters in Uploaded Avatars Show as Broken and Avatars not showing up on Migrated Forum but can’t seem to solve my version of the problem. I might need a modern version of <user_id>, upload_id: 2) to fix the issue.

Here’s an example of user zeeeblob in the ‘latest’ listing:

http://localhost:3000/user_avatar/localhost/zeeeblob/120/111_1.png - Works! :smile:
http://localhost:3000/user_avatar/localhost/zeeeblob/25/111.png - doesn’t work :frowning:

I tried rake posts:rebake but that doesn’t seem to solve the issue either. Can someone please explain to me why I am experiencing this and how to go about fixing it?

Thank you.

(Fernando Stefanini) #2

I’m experiencing the same problem now.
Did you ever find a fix or workaround for this?



Make a backup of your forum. Put it in read only mode or switch off the app just to be safe. Then:

  • $ ssh <server>
  • # cd /var/discourse
  • # ./launcher enter app

From here you can do two things:

  1. The best answer is probably to rake posts:rebake but if it doesn’t work for you or would take too long you can
  2. # rails c then use active record to perform a 100% definitive, 0% greedy update_all query for the cooked column.

Examine your cooked posts, thumbnail urls that are working vs not working and do something along the lines of:

  • # Post.update_all("replace(cooked, 'faulty_thumbnail_url', 'working_thumbnail_url')")

Definitely err on the side of caution. You can use other postgres string functions and .where() to form tighter query constraints on the cooked data. See active record docs and postgres docs for more information. Below is an expandable description of the posts table for reference.