Excerpts truncating at 50 characters

I had topic excerpts working as desired — that is, they observed post_excerpt_maxlength in all cases. I first did this with a plugin (which worked), then learned about SiteSetting.always_include_topic_excerpts = true, so switched to that. Still worked.

About two days ago, perhaps after applying 2.4.0.beta4, excerpts started truncating at 50 characters. Very mysterious.

I’ve tried flipping SiteSetting.always_include_topic_excerpts and reinstalling the plugin, and changing the value of post_excerpt_maxlength, but no change. Still stuck at 50 characters.

Anybody else seeing this? Dunno what else to try.

Could this be a bug @neil?

Another point is that it’s affecting only new topics. Older topics with longer excerpts still have them.

Adding a post to such a topic doesn’t shorten the excerpt (unsurprising), but editing the first post does cause the excerpt to newly truncate at 50 chars.

So while I haven’t looked (Discourse noob), it seems that excerpts are a database field, and the truncation only happens on a record update.

LQ

1 Like

The plugin you linked to has hard-coded 50:

https://github.com/hnb-ku/discourse-topic-excerpt-plugin/blob/master/plugin.rb#L8

You can fork the plugin and put SiteSetting.post_excerpt_maxlength instead of 50, or @Johani can update it for you.

5 Likes

That plugin hasn’t been updated for almost two years now and it predates the addition of the always_include_topic_excerpts setting. You should not be using it at all. I’ve added a deprecation notice and will delete that repository in a week or so.

Please remove that outdated plugin, enable the always_include_topic_excerpts setting and report back if you still have the same problem.

6 Likes

This seems to work. I had been thrown off because applying the plugin got me the (300 char) excerpts I wanted, where before I had none. I suppose that only subsequently-created topics exhibited the hard-coded 50.

One wrinkle: Existing topics with 50 char excerpts still have them. It seems necessary to touch the OP of these topics to lengthen their excerpts to post_excerpt_maxlength. Any way to automate that? Thanks.

LQ

You’ll need to rebake the posts in order for the them to follow the new limit. More on that here.

2 Likes

Are these truly interchangeable today?

rake posts:rebake

bundle exec rake posts:rebake

Because the first rake task completed without issue but didn’t regenerate the excerpts. Nevertheless, site was running.

Then tried with be. This exited with:

rake aborted!
PG::ConnectionBad: FATAL:  Peer authentication failed for user "discourse"

… followed by a stack trace. Now, topic pages are unreachable. Home page is reachable, and most of admin is reachable — though charts on admin home fail to load. Running …

rake posts:rebake

… doesn’t fix things. Eventually rebooted the droplet, but the condition persists. Any help appreciated.

LQ

Yes, I just tried both

$ cd /var/discourse
$ ./launcher enter app
$ bundle exec rake posts:rebake

Rebaking post markdown for 'default'
      297 / 297 (100.0%)
297 posts done!
--------------------------------------------------
$ cd /var/discourse
$ ./launcher enter app
$ rake posts:rebake

Rebaking post markdown for 'default'
      297 / 297 (100.0%)
297 posts done!

and they worked without issue.

This implies that you have other problems. Did you follow the supported installation guide when you set your site up?

2 Likes

Yes. Installed exactly as stated in INSTALL-cloud.md

Only difference is that it’s 19.04. Haven’t updated any gems manually or anything like that.

Here’s the full output of bundle exec rake posts:rebake --trace

I can’t say for sure, but I think you might have two separate problems.

Try the following to narrow this down a bit more.

  • remove any non-official plugins
  • rebuild the app
  • try safe-mode and see if the app loads

Are you seeing any errors in your browser console on the broken pages?

1 Like

Removed footnotes and checkbox plugins. Not sure if those are official. Rebuilt. No console errors on non-safe mode load. Site is up.

Any benefit to testing safe mode for console errors? If not, would appear to be one of those plugins.

Yes, those are official, but be sure that you’re not using a fork of some sort. Official plugins have a checkmark next to their names in the admin

pluginPage01

and are hosted under https://github.com/discourse/

I just tried both on the latest and I’m not able to reproduce the issue you’re having - the site not loading.

If there’s no errors in the normal, non-safe mode, then you don’t need to check that in safe-mode.

I’m guessing the excerpts have still not been updated?

Have you checked your.site.com/logs ?

1 Like

No, but it’s a young instance. I’m gonna let it go.

Yeah, nothing exciting. I do unattended-upgrades and it looks like dpkg was maybe running at rebake time. Not gonna sweat it.

Appreciate the help.

LQ

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.