WP-Discourse 插件的最新提交导致所有自定义帖子(通过 EventON 插件创建)都被归因于 system 用户,尽管该用户同时存在于 Discourse 和 WordPress 中。
如果回滚到 2.3.7 版本,它会按预期工作,但更新到 2.3.8 版本会导致此错误发生。
我们通过电子邮件收到此错误:
失败原因:
Discourse 返回了 400 响应代码。
param 缺失或值为空:post
你是指? post
post[raw]
controller
title
我认为这有助于识别可能的原因。
angus
(Angus McLeod)
2022 年2 月 21 日 07:52
2
嘿,你能分享一下你提到的插件的链接吗?另外,你在 WP Discourse 日志中看到什么了吗?
您好 @angus
插件在这里:https://www.myeventon.com/
您需要插件 v2.3.7 或 v2.3.8 的日志吗?
1 个赞
v2.3.7:
[2022-02-21 08:07:11] publish.INFO: create_post.post_success {"wp_title":"[Please Ignore] Test Event","wp_author_id":"3958","wp_post_id":126070,"discourse_post_id":""}
[2022-02-21 08:07:11] publish.INFO: create_post.body_valid {"wp_title":"[Please Ignore] Test Event","wp_author_id":"3958","wp_post_id":126070,"discourse_post_id":""}
使用 2.3.7 版本,帖子已成功链接到我在 wordpress 和 discourse 上的用户帐户。
v2.3.8:
[2022-02-21 08:10:15] publish.INFO: create_post.post_success {"wp_title":"[Please Ignore] Another test event","wp_author_id":"3958","wp_post_id":126071,"discourse_post_id":""}
[2022-02-21 08:10:15] publish.INFO: create_post.body_valid {"wp_title":"[Please Ignore] Another test event","wp_author_id":"3958","wp_post_id":126071,"discourse_post_id":""}
使用 2.3.8 版本,帖子已链接到我在 wordpress 上的用户和 discourse 上的系统用户。
1 个赞
是的,帖子已成功发布,但在 v2.3.8 中错误地将用户(系统)归属。
angus:
您以前没有看到 400 错误
不,我们在 wp-discourse 插件的任何先前版本中都没有看到任何 400 错误。
这些用户是 WordPress 上的非管理员注册用户,到目前为止对我们来说一直有效。任何用户都能正确链接到 Discourse。
这是一个全局 API 密钥
1 个赞
angus
(Angus McLeod)
2022 年2 月 21 日 14:24
8
当此 PR 合并后(并且版本已推送到 Wordpress.org ),该功能将按预期工作。
main ← angusmcleod:two_three_nine
opened 02:16PM - 21 Feb 22 UTC
2 个赞
我遇到了同样的错误,并可以确认是在升级 WP Discourse 到 2.3.8 版本后开始的。
使用此版本,主题会被创建,但使用的是默认用户。
为确认这一点,我将 WP Discourse 回滚到了 2.3.7 版本,现在它又能正常工作了。
2 个赞
angus
(Angus McLeod)
2022 年2 月 22 日 06:36
10
谢谢,这将在合并 PR 时得到处理。您能否也确认这两个问题?
正在发布帖子的用户类型(您期望使用其 Discourse 用户名)是什么(例如,他们是管理员还是非管理员)?
您正在使用哪种类型的 API 密钥将 WordPress 连接到 Discourse?
这里也有同样的问题。不是自定义帖子类型。
不是管理员用户,而是版主
“所有用户”API 密钥。
angus
(Angus McLeod)
2022 年2 月 22 日 19:13
13
大家好,2.3.9 版本现已上线,修复了此问题。请更新并告知我进展。
1 个赞
orenwolf
(Ken Snider)
2022 年2 月 23 日 16:29
14
我们遇到了 2.3.9 的相同问题,并将回滚到 2.3.7,并禁用此插件的自动更新。
1 个赞
您好 @angus
抱歉打扰,我的问题似乎已在 WordPress 5.9.1 和 WP Discourse 2.3.9 中得到修复。
但是,似乎 Discourse 现在会对每个已发布的帖子进行一些额外处理,并且所有权在事后从系统用户转移到了发布用户?
1 个赞
angus
(Angus McLeod)
2022 年2 月 23 日 17:40
16
嘿 @orenwolf ,很抱歉听到您仍然遇到问题。您能否确认您期望的用户是否在他们的 WordPress 个人资料中拥有“Discourse 用户名”?
总的来说,感谢您对此的耐心。在我自己的各种站点测试(以及插件自身的单元测试)中,“Discourse 用户名”功能在“2.3.9”版本上现已按预期运行。如果您仍有问题,请确认您使用的是最新版本的插件,并且您期望的作者拥有“Discourse 用户名”。
您可能想知道为什么会出现这个问题。我认为提供一些背景信息(这也将回答您的问题 @itsbhanusharma )会很有帮助。以前,此功能的工作方式是使用“Api-Username”标头中的不同用户(参见此处 )。之所以认为这是必要的,是因为 Discourse 中的相关终结点不支持设置与执行 API 请求的用户不同的帖子创建者。
其结果是,此功能仅在您拥有“所有用户”API 密钥和“全局”范围时才有效。我只想指出,一段时间以来,创建 WP Discourse 插件 API 密钥的标准说明如下:
如果您尚未创建 API 密钥,请点击“新建 API 密钥”,将用户级别设置为“单个用户”,将“用户”设置为管理员帐户,选择“全局密钥”并点击“保存”。在此处复制并粘贴 API 密钥。
遵循这些说明意味着此(未记录的)功能将不起作用,并且已为各种站点造成了问题。
此外,出于各种安全原因,我已逐步对插件进行更改,以允许使用更具体的 API 密钥。这将需要对 Discourse 进行更改,并且(在合并后)将允许插件管理员自行颁发新的、限制性更强的 API 密钥。届时我将对此进行公告。
main ← angusmcleod:fix_wordpress_scopes
opened 09:46AM - 20 Dec 21 UTC
I'm looking to add granular API key usage for the WP Discourse plugin. This invo… lves:
- Updating the "wordpress" default mappings to reflect the actions being used by the plugin, grouped by the feature-set they relate to (note that the existing "wordpress" action in the "topic" resource only relates to comment retrieval in the plugin, and is somewhat confusing in its current state).
- Adding a ``session/scopes`` endpoint, which returns the scopes associated with the api key in the request.
This is the companion PR on the plugin, which will provide further context to this: https://github.com/discourse/wp-discourse/pull/431. See in particular [``validate_scopes``](https://github.com/discourse/wp-discourse/pull/431/files#diff-5fd9ce264afeb5f617119db36e34a2e5a33f605527ac6fa9ee761b8123f1a17eR185).
If this approach is acceptable, I'll do some more testing before moving this out of draft. Below are some Q/A explaining my thinking behind this.
### Why does the wordpress plugin need granular scopes?
Currently the plugin requires the use of a global key, but only uses a subset of the actions, creating more risk than necessary. [See for example](https://meta.discourse.org/t/what-scopes-exactly-does-the-wordpress-api-key-need/175812).
### Why group the scopes by feature set?
This is how people use the plugin. Some use only SSO, some only publishing, some without comments etc. If a user is not using SSO they should be able to use a key that doesn't include the ``admin/user`` actions SSO requires.
Currently the "publishing" feature set cannot be totally disabled in the plugin (hence the "(required)" in the action description), however the ability to disable it (and just use SSO) may be added.
### Why add a ``session/scopes`` endpoint?
The WP Discourse plugin currently sends a request to ``/users/:username`` to test its connection to Discourse. This may be successful even if the allowed scopes are insufficient for how the plugin is configured.
A scopes endpoint tells the API consumer both whether the connection is successful and what scopes their key has. There's similar implementations in other APIs, e.g [Sendgrid](https://docs.sendgrid.com/api-reference/api-key-permissions/retrieve-a-list-of-scopes-for-which-this-user-has-access).
### Why add the ``scopes`` endpoint to the session controller?
The endpoint could go in a few different places. I figured it belonged there as essentially you're asking about the scopes in the session created when the api-authenticated request is made.
### Why not use a ``tokeninfo`` endpoint?
``tokeninfo`` endpoints are part of the OAuth 2.0 spec, which is not what we're dealing with here. Using it may be confusing.
是的 @itsbhanusharma ,此功能现在的工作方式是,在创建帖子后(如果存在“Discourse 用户名”),会发出第二个请求来更改帖子的所有者。实际上,这是通过 Discourse API 任意设置帖子所有者的唯一正确方法(而无需如上所述使用 Api-Username 和所有用户全局密钥)。考虑到这是什么类型的操作,这不应成为性能问题。
4 个赞
这不是一个性能问题,只是向不太懂技术的人解释他们帖子顶部的铅笔图标是正常的,而且它将保持不变,这会有点麻烦。
这需要一些时间,但最终我们会习惯的。
帖子显示为已编辑,这有点令人不快,但只要一切正常,那就没关系。
然而,通知错误是一个问题。它们显示新帖子是由系统用户创建的。
到目前为止,这感觉就像一种权宜之计,而不是解决方案。无法自动以正确用户的身份发帖,这无疑是向后迈出的一大步。我不确定是什么导致了这个问题。
angus
(Angus McLeod)
2022 年2 月 24 日 12:44
19
简而言之,出于各种原因,我一直在逐步更改插件处理所有与 discourse 请求的方式,特别是为了测试和安全。在此处无法详述这些更改的完整背景和理由。我理解就此特定功能而言,这可能感觉像是“没坏就别修”,但这里有更广泛的背景。
这些更改已经进行了一段时间(数月),但它们现在浮出水面的原因是我在 2.3.8 版本中犯了一个错误。因此,我在 2.3.9 版本中包含了本应在该版本中进行的更改。
话虽如此,@jtbayly @itsbhanusharma 我听到了你们对这个特定功能的不同处理方式的反馈。我理解这可能感觉像是一种权宜之计。但事实并非如此。尽管如此,鉴于你们的反馈,我将在插件中添加现有的方式,并提供一个设置供你们选择使用(将在 2.4.0 版本中上线)。我将在未来几天合并后跟进通知。
我希望在解决你们两人提出的问题后,能够完全消除这种方法,这很可能需要对 discourse/discourse 进行进一步的更改。如前所述,我将在下个月(取决于何时将更改合并到 discourse/discourse)就插件处理 API 密钥的方式的更改发布更广泛的公告,其中将涵盖这方面的内容。
4 个赞
jtbayly:
我不确定我是否明白最初是什么导致了这个问题。
我说这话的意思是承认我不确定是否还有其他前进的道路。并不是“你为什么要去弄坏它!”的评论。
非常感谢您在更新核心 Discourse 的同时,努力维护 WP 插件的正常工作。并且非常高兴核心(很可能)即将进行的更改将允许在此领域进行改进。
1 个赞