# 发布到 Discourse 时出现严重错误

**URL:** https://meta.discourse.org/t/critical-error-on-publish-post-to-discourse/200009
**Category:** WordPress
**Created:** [2021年八月10日 22:17 UTC](https://meta.discourse.org/t/critical-error-on-publish-post-to-discourse/200009 "2021-08-10T22:17:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![oreillyc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oreillyc/32/212955_2.png) [@oreillyc](https://meta.discourse.org/u/oreillyc)
#### Post date: [2021年八月10日 22:17 UTC](https://meta.discourse.org/t/critical-error-on-publish-post-to-discourse/200009/1 "2021-08-10T22:17:54Z")

</div>

使用最新的 Discourse 和 [WP Discourse](https://github.com/discourse/wp-discourse) WordPress 插件时，尝试将文章发布到 Discourse 会出现以下错误：

在文件 /www/sociocracyforall\_679/public/wp-content/themes/Divi/includes/builder/feature/gutenberg/blocks/Layout.php 的第 207 行发生 E\_ERROR 类型错误。错误信息：未捕获的 ArgumentCountError：函数 ET\_GB\_Block\_Layout::get\_the\_excerpt() 的参数太少，在 /www/sociocracyforall\_679/public/wp-includes/class-wp-hook.php 的第 303 行只传递了 1 个参数，但该函数在 /www/sociocracyforall\_679/public/wp-content/themes/Divi/includes/builder/feature/gutenberg/blocks/Layout.php 的第 207 行需要恰好 2 个参数。  
堆栈跟踪：  
#0 /www/sociocracyforall\_679/public/wp-includes/class-wp-hook.php(303): ET\_GB\_Block\_Layout-\>get\_the\_excerpt(‘It was yet anot…’)  
#1 /www/sociocracyforall\_679/public/wp-includes/plugin.php(189): WP\_Hook-\>apply\_filters(‘It was yet anot…’, Array)  
#2 /www/sociocracyforall\_679/public/wp-content/plugins/wp-discourse/lib/discourse-publish.php(271): apply\_filters(‘get\_the\_excerpt’, ‘It was yet anot…’)  
#3 /www/sociocracyforall\_679/public/wp-content/plugins/wp-discourse/lib/discourse-publish.php(209): WPDiscourse\DiscoursePublish\DiscoursePublish-\>sync\_to\_discourse\_work(32452, ‘The day I conse…’, ’

这看起来像是不同版本间参数变更导致的 bug，对吧？

---

<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: [2021年八月11日 01:13 UTC](https://meta.discourse.org/t/critical-error-on-publish-post-to-discourse/200009/2 "2021-08-11T01:13:26Z")

</div>

嘿，CJ，看起来错误来自 Divi 插件或其某个扩展。

> [@oreillyc](#):
>
> 在文件 /www/sociocracyforall\_679/public/wp-content/themes/Divi/includes/builder/feature/gutenberg/blocks/Layout.php 的第 207 行触发了 E\_ERROR 类型错误。错误信息：Uncaught ArgumentCountError: 函数 ET\_GB\_Block\_Layout::get\_the\_excerpt() 的参数太少。

确实，如果你在谷歌搜索 `ET_GB_Block_Layout`，会发现许多其他网站也遇到了相同的问题（在许多情况下，该问题会出现在谷歌抓取的 HTML 中）。你应该检查是否运行了该插件的最新版本，并考虑向 Elegant Themes 报告此问题。

[WP Discourse](https://github.com/discourse/wp-discourse) 代码出现在堆栈跟踪中（通常位于更靠后的位置，这通常意味着它并非问题的根源），是因为每次点击发布按钮时，任何发布后执行的代码都会以相互关联的方式运行。

如果发布后出现任何异常，无论其来源如何，[WP Discourse](https://github.com/discourse/wp-discourse) 插件的代码很可能都会在堆栈跟踪的某个位置出现。但这并不意味着它就是问题的根源。

---

<div class="post-metadata">

### Author: ![oreillyc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oreillyc/32/212955_2.png) [@oreillyc](https://meta.discourse.org/u/oreillyc)
#### Post date: [2021年八月11日 18:07 UTC](https://meta.discourse.org/t/critical-error-on-publish-post-to-discourse/200009/3 "2021-08-11T18:07:26Z")

</div>

而且这确实只在启用 Divi 时发生。

希望他们能修复这个问题 🙂

以下是完整的堆栈跟踪供参考：

```plaintext
ArgumentCountError: 未捕获的异常 'ArgumentCountError'，消息为“函数 ET_GB_Block_Layout::get_the_excerpt() 的参数太少，在 /www/sociocracyforall_679/public/wp-includes/class-wp-hook.php 第 303 行传递了 1 个参数，但恰好需要 2 个”，位于 /www/sociocracyforall_679/public/wp-content/themes/Divi/includes/builder/feature/gutenberg/blocks/Layout.php:207
在 ET_GB_Block_Layout::get_the_excerpt 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/class-wp-hook.php (303)
在 WP_Hook::apply_filters 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/plugin.php (189)
在 apply_filters 中被调用，位置：/www/sociocracyforall_679/public/wp-content/plugins/wp-discourse/lib/discourse-publish.php (271)
在 WPDiscourse\\DiscoursePublish\\DiscoursePublish::sync_to_discourse_work 中被调用，位置：/www/sociocracyforall_679/public/wp-content/plugins/wp-discourse/lib/discourse-publish.php (209)
在 WPDiscourse\\DiscoursePublish\\DiscoursePublish::sync_to_discourse 中被调用，位置：/www/sociocracyforall_679/public/wp-content/plugins/wp-discourse/lib/discourse-publish.php (158)
在 WPDiscourse\\DiscoursePublish\\DiscoursePublish::publish_post_after_save 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/class-wp-hook.php (305)
在 WP_Hook::apply_filters 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/class-wp-hook.php (327)
在 WP_Hook::do_action 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/plugin.php (470)
在 do_action 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/post.php (5180)
在 wp_after_insert_post 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/post.php (4482)
在 wp_insert_post 中被调用，位置：/www/sociocracyforall_679/public/wp-includes/post.php (4570)
在 wp_update_post 中被调用，位置：/www/sociocracyforall_679/public/wp-admin/includes/post.php (423)
在 edit_post 中被调用，位置：/www/sociocracyforall_679/public/wp-admin/post.php (227)

```
