# WPDiscourse - 登出无效

**URL:** https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011
**Category:** WordPress
**Created:** [2022年七月5日 18:34 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011 "2022-07-05T18:34:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Fma965](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fma965/32/259795_2.png) [@Fma965](https://meta.discourse.org/u/Fma965)
#### Post date: [2022年七月5日 18:34 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/1 "2022-07-05T18:34:31Z")

</div>

?request=logout

导致以下结果

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/b/e/fbe252c4f7b1089d9ac667471188e364924ae3fb.png)

```plaintext
致命错误：无法将对象 stdClass 用作数组，位于 /var/www/vhosts/localhost/html/wp-includes/http.php:251 堆栈跟踪：#0 /var/www/vhosts/localhost/html/wp-content/plugins/wp-discourse/lib/plugin-utilities.php(188): wp_remote_retrieve_response_code() #1 /var/www/vhosts/localhost/html/wp-content/plugins/wp-discourse/lib/sso-client/client.php(477): WPDiscourse\DiscourseBase->validate() #2 /var/www/vhosts/localhost/html/wp-includes/class-wp-hook.php(307): WPDiscourse\SSOClient\Client->logout_from_discourse() #3 /var/www/vhosts/localhost/html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #4 /var/www/vhosts/localhost/html/wp-includes/plugin.php(476): WP_Hook->do_action() #5 /var/www/vhosts/localhost/html/wp-includes/pluggable.php(1104): do_action() #6 /var/www/vhosts/localhost/html/wp-includes/pluggable.php(660): wp_clear_auth_cookie() #7 /var/www/vhosts/localhost/html/wp-content/plugins/wp-discourse/lib/sso-client/query-redirect.php(68): wp_logout() #8 /var/www/vhosts/localhost/html/wp-includes/class-wp-hook.php(307): WPDiscourse\SSOClient\QueryRedirect->discourse_sso_url_redirect() #9 /var/www/vhosts/localhost/html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #10 /var/www/vhosts/localhost/html/wp-includes/plugin.php(524): WP_Hook->do_action() #11 /var/www/vhosts/localhost/html/wp-includes/class-wp-query.php(1104): do_action_ref_array() #12 /var/www/vhosts/localhost/html/wp-includes/class-wp-query.php(1792): WP_Query->parse_query() #13 /var/www/vhosts/localhost/html/wp-includes/class-wp-query.php(3586): WP_Query->get_posts() #14 /var/www/vhosts/localhost/html/wp-includes/class-wp-query.php(3718): WP_Query->query() #15 /var/www/vhosts/localhost/html/wp-content/plugins/happyfiles-pro/includes/data.php(197): WP_Query->__construct() #16 /var/www/vhosts/localhost/html/wp-includes/class-wp-hook.php(307): HappyFiles\Data::get_folders() #17 /var/www/vhosts/localhost/html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters() #18 /var/www/vhosts/localhost/html/wp-includes/plugin.php(476): WP_Hook->do_action() #19 /var/www/vhosts/localhost/html/wp-settings.php(598): do_action() #20 /var/www/vhosts/localhost/html/wp-config.php(85): require_once('...') #21 /var/www/vhosts/localhost/html/wp-load.php(50): require_once('...') #22 /var/www/vhosts/localhost/html/wp-blog-header.php(13): require_once('...') #23 /var/www/vhosts/localhost/html/index.php(17): require('...') #24 {main} 在 /var/www/vhosts/localhost/html/wp-includes/http.php 第 251 行抛出

```

---

<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: [2022年七月5日 18:49 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/2 "2022-07-05T18:49:24Z")

</div>

我明天早上欧洲中部时间第一件事就来看看。

---

<div class="post-metadata">

### Author: ![Fma965](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fma965/32/259795_2.png) [@Fma965](https://meta.discourse.org/u/Fma965)
#### Post date: [2022年七月5日 18:54 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/3 "2022-07-05T18:54:35Z")

</div>

没问题，谢谢。可能是我这边的问题，但如果你能复现的话，知道一下也好。

这是最新版本的 WordPress 和 [Discourse Connect](https://meta.discourse.org/t/13045?silent=true) 以及 Discourse。

它也是 PHP 8（这可能是问题所在？）

我将 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 用作客户端而不是提供者，不知道这是否重要？

我最终会将其切换到 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: [2022年七月6日 06:00 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/4 "2022-07-06T06:00:05Z")

</div>

该主题已在 10 小时后自动关闭。不再允许回复。

---

<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: [2022年七月6日 07:19 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/5 "2022-07-06T07:19:35Z")

</div>



---

<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: [2022年七月6日 11:09 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/6 "2022-07-06T11:09:54Z")

</div>

@Fma965 这是一个真正的bug。它已经存在将近一年了。当

- 使用 WP 作为 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 客户端时；
- 启用同步登出时；以及
- （这也取决于您的 php 错误处理）  
时会出现此问题。

感谢您的报告！

一旦此 PR 被合并并且 `2.4.5` 发布，它将被修复。

> <https://github.com/discourse/wp-discourse/pull/451>
>
> \- Fix logout when WP is the DiscourseConnect client and sync logout is enabled (…see https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011)
> \- Improve the wpdc\_publish\_body filter to cover more use cases (https://meta.discourse.org/t/how-to-tag-posts-that-are-published-from-wordpress-to-discourse/99927)

抄送 @simon

---

<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: [2022年七月6日 17:27 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/7 "2022-07-06T17:27:13Z")

</div>

感谢 @Fma965 和 @angus，[WP Discourse](https://github.com/discourse/wp-discourse) 2.4.5 版本现已在 WordPress 存储库中提供。

---

<div class="post-metadata">

### Author: ![Fma965](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fma965/32/259795_2.png) [@Fma965](https://meta.discourse.org/u/Fma965)
#### Post date: [2022年七月7日 09:18 UTC](https://meta.discourse.org/t/wpdiscourse-logout-not-working/232011/8 "2022-07-07T09:18:59Z")

</div>

谢谢 Angus，我已经把 SSO 方向改过来了，比我想象的要简单，只需导入用户并将其标记为已验证，然后让用户重置密码即可。

不过，因为这样我无法进行测试，但我相信它能按预期工作，感谢你这么快就解决了。

也感谢 @simon 发布了它。
