# Discourse未能在文章下自动关联评论

**URL:** https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364
**Category:** WordPress
**Created:** [2024年三月14日 16:39 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364 "2024-03-14T16:39:54Z")
**Posts on this page:** 12
**Page:** 2

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2024年四月20日 20:12 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/21 "2024-04-20T20:12:45Z")

</div>

> [@Miasanrot](#):
>
> 还有哪些工具？

WP Rocket 应该可以。你可能需要对显示 Discourse 评论的 WordPress 页面进行一些调整来清除缓存。这里有一个很好的建议：[WP Discourse comment webhook does not trigger a WP Rocket Cache refresh - #13 by Brandon007](https://meta.discourse.org/t/wp-discourse-comment-webhook-does-not-trigger-a-wp-rocket-cache-refresh/236700/13?u=simon%E3%80%82WP) Discourse 的“ajax load”选项也是一个合理的解决方法。

这似乎是真正的问题：  
`[2024-03-14 06:02:59] comment.ERROR: sync_comments.response_error {"message":"Forbidden","discourse_topic_id":"","wp_post_id":13514,"http_code":403} `

这表明当 [WP Discourse](https://github.com/discourse/wp-discourse) 插件尝试拉取评论时，Discourse 返回了 `403` 响应（禁止）。（错误是从这里记录的：[wp-discourse/lib/discourse-comment.php at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/blob/main/lib/discourse-comment.php#L230%EF%BC%89)

这只是一个猜测，但这个插件表明你的 WordPress 网站位于代理后面：

> [@Miasanrot](#):
>
> `Proxy Real IP - 1.1`

这可能会触发 Discourse 上的 `403` 错误。也许请求头配置不正确？我对此了解不多。但是，你可以通过在 Discourse 网站的错误日志页面打开的情况下，从 WordPress 发布一篇文章来确认这是否是一个问题。

点击此链接可转到错误日志页面：

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/2/b/d2b291b6dc87107e4adaa7cf8023e9aef85a0dd7.png)

我 _认为_ `403` 响应会在日志中触发一个条目。如果触发了，请在此处分享（已编辑的）错误消息。

---

<div class="post-metadata">

### Author: ![Miasanrot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miasanrot/32/364805_2.png) [@Miasanrot](https://meta.discourse.org/u/Miasanrot)
#### Post date: [2024年四月21日 14:47 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/22 "2024-04-21T14:47:26Z")

</div>

谢谢！我一有空就会尝试一下。

我还发现之前的缓存似乎与插件 GridPane Redis Object Cache 和 Nginx Helper 一起工作。所以也许我安装 WP Rocket 是不必要的。但禁用其中任何一个也没有帮助。

另外，评论计数目前也不起作用。即使清除缓存，最新文章的数字仍停留在 16（Discourse 目前有 18 条评论）

如前所述：ajax 选项已激活。

我稍后或明天会做那个关于日志的事情。

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2024年四月21日 16:04 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/23 "2024-04-21T16:04:44Z")

</div>

是的，任何流行的缓存插件都应该可以工作。只需安装一个并尝试了解它的作用。对于调试问题，暂时禁用缓存可能会很有用。这样您就可以确认问题不是由缓存引起的。

> [@Miasanrot](#):
>
> 评论计数目前也不起作用。

评论计数是从返回此错误的函数设置的：

`[2024-03-14 06:02:59] comment.ERROR: sync_comments.response_error {"message":"Forbidden","discourse_topic_id":"","wp_post_id":13514,"http_code":403} `

如果您仍然收到该错误，评论计数将不会更新。

在网站上安装了 Proxy Real IP - 1.1 插件表明其服务器配置相当复杂。也许可以咨询设置网站的人以获取详细信息。您也可以考虑将网站迁移到可以为您处理此类事务的托管服务。

> [@Miasanrot](#):
>
> 稍后或明天我会做那个关于日志的事情。

我昨天对问题是否会出现在 Discourse 错误日志中没有昨天那么确定了，但仍然值得一试。

---

<div class="post-metadata">

### Author: ![Miasanrot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miasanrot/32/364805_2.png) [@Miasanrot](https://meta.discourse.org/u/Miasanrot)
#### Post date: [2024年四月21日 16:33 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/24 "2024-04-21T16:33:07Z")

</div>

> [@simon](#):
>
> 安装了 Proxy Real IP - 1.1 插件表明其服务器配置相当复杂。

它已安装，但未在我们德语页面上激活，仅在我们英语页面上激活。几周前我问了接手我之前负责该页面的人关于这个插件的事情，只是忘记了也在英语页面上停用它。Discourse 只连接到我们德语页面，在那里它未被激活。所以我猜它目前没有功能。

我真希望我对所有这些事情能有更多的了解，因为我有时也觉得WordPress运行非常缓慢，而且我只是在网上随便看看，并没有真正弄懂所有这些东西。

澄清一下：我主要说的是 [miasanrot.de](http://miasanrot.de) / [miasanrot.com](http://miasanrot.com) 未连接到 Discourse。所以这个网站使用的是WordPress的正常评论系统。

---

<div class="post-metadata">

### Author: ![Miasanrot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miasanrot/32/364805_2.png) [@Miasanrot](https://meta.discourse.org/u/Miasanrot)
#### Post date: [2024年四月21日 16:56 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/25 "2024-04-21T16:56:50Z")

</div>

> [@simon](#):
>
> 我昨天对问题是否会在 Discourse 错误日志中显示没有昨天那么确定了，但仍然值得一试。

你的感觉是对的。我发布了一篇带有错误日志的文章，但它没有显示在 Discourse 的错误日志中。

现在情况更糟了：新文章没有显示给未登录 WP 的用户。所以页面就像冻结了一样。

更新 2：它现在显示了正确的评论数量和新文章，但我不太清楚是什么改变了。一个盲猜：我停用了之前提到的两个缓存插件，只启用了 WP rocket。我尝试重新激活这两个插件，但没有任何改变。然后我在编辑器中更新了文章，它就生效了。所以其中一个插件（nginx helper）说“每当帖子被编辑/发布时，清除 nginx 的 fastcgi/proxy 缓存或 redis-缓存。还做了其他一些事情。”——所以我猜是这个过程现在帮助页面正常显示了。

我认为我可以停用 WP Rocket 了，但缓存方面还是有些不对劲，我感觉这可能与 Discourse 问题有关。

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2024年四月21日 17:23 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/26 "2024-04-21T17:23:11Z")

</div>

您的主要问题绝对是其他问题，但您为什么要使用 Nginx-helper？WP Rocket 会制作静态副本，您不需要另一个用于 fastcgi 和 Redis 的缓存（当然，在某些情况下，即使有 WP Rocket，PHP 调用也可能需要缓存，但这些网站通常不使用 WP Rocket，而是使用更高级别的工具）。

但缓存意味着没有任何动态内容发生。

---

<div class="post-metadata">

### Author: ![Miasanrot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miasanrot/32/364805_2.png) [@Miasanrot](https://meta.discourse.org/u/Miasanrot)
#### Post date: [2024年四月21日 17:25 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/27 "2024-04-21T17:25:26Z")

</div>

接手这个博客时它就已经安装了。说实话，我不知道为什么。我只知道一旦我停用它，页面就无法更新。所以是的，问题可能就在那个方向上。

编辑：我现在去检查了一下。停用了插件，页面无法更新。激活了插件并更新了一篇文章，评论数量显示正确。

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2024年四月21日 17:33 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/28 "2024-04-21T17:33:17Z")

</div>

一个粗略的猜测是，您应该查看 `wp-config.php` 试图做什么。最前面的几行可能会提供线索。

但再说一遍。您应该禁用所有插件，并使用一个基本主题，如 2020，然后尝试 Discourse 是否按预期运行。如果是，那么一些插件或主题就是问题所在。

首先备份您的数据库。禁用插件和主题可能会给您带来意想不到的惊喜。如果您还没有，WP-CLI 值得搜索一下。

但如果它仍然与您作对……希望这里的某些专家能提供帮助。

无论如何——您应该考虑您正在使用哪些插件以及您是否真的需要它们。

---

<div class="post-metadata">

### Author: ![Miasanrot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/miasanrot/32/364805_2.png) [@Miasanrot](https://meta.discourse.org/u/Miasanrot)
#### Post date: [2024年四月21日 18:01 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/29 "2024-04-21T18:01:37Z")

</div>

> [@Jagster](#):
>
> 但再说一遍。你应该禁用所有插件并使用一个基本主题

我计划一有时间并且流量不是那么大的时候就这么做。目前很难找到一天可以进行这样的测试。但我会做的。

还有一个观察：  
当我直接发布文章而不先将其设为私有时（我通常在不想直接发布时这样做），Discourse 会将主题正确地链接到文章。（显示的评论数量仍然是错误的，但评论显示在文章下方）

---

<div class="post-metadata">

### Author: ![steelmaiden](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steelmaiden/32/125527_2.png) [@steelmaiden](https://meta.discourse.org/u/steelmaiden)
#### Post date: [2025年一月14日 18:35 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/30 "2025-01-14T18:35:54Z")

</div>

**我也遇到了同样的问题。** 评论已停止显示，并且我看到了那些 `sync_comments` 错误。我不确定它具体是什么时候开始的，但我偶尔会更新 WordPress 和插件。

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年一月15日 08:31 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/31 "2025-01-15T08:31:03Z")

</div>

嘿 @steelmaiden，请在 #Support > WordPress 中创建一个新主题，并：

1. 描述您看到的行为。
2. 描述预期的行为。
3. 分享您拥有的任何错误日志，以及日志查看器中的“meta”文件或下载的日志。

谢谢。

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2025年一月15日 08:31 UTC](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364/32 "2025-01-15T08:31:35Z")

</div>



[上一頁](https://meta.discourse.org/t/discourse-not-linking-the-comments-automatically-under-the-articles/299364.md?page=1)
