我为wp-cli编写了一个名为wp nurse的命令。它以wp doctor命令为样式,但用于运行WordPress站点健康检查的除外。使用浏览器中的工具,所有16个测试目前都通过了.然而,当从wp调用它时,只有13个测试成功。
ichabod:~ uplime% wp nurse check --all
+----------------------+-------------+--------------------------------------------------------+
| name | status | message |
+----------------------+-------------+--------------------------------------------------------+
| wordpress_version | good | Your version of WordPress (5.3) is up to date |
| plugin_version | good | Your plugins are all up to date |
| theme_version | good | Your themes are all up to date |
| php_version | good | Your version of PHP (7.3.12) is up to date |
| sql_server | good | SQL server is up to date |
| php_extensions | good | Required and recommended modules are installed |
| utf8mb4_support | good | UTF8MB4 is supported |
| https_status | good | Your website is using an active HTTPS connection. |
| ssl_support | good | Your site can communicate securely with other services |
| scheduled_events | good | Scheduled events are running |
| http_requests | good | HTTP requests seem to be working as expected |
| debug_enabled | good | Your site is not set to output debug information |
| rest_availability | recommended | The REST API encountered an unexpected result |
| dotorg_communication | good | Can communicate with WordPress.org |
| background_updates | critical | Background updates are not working as expected |
| loopback_requests | recommended | Your site could not complete a loopback request |
+----------------------+-------------+--------------------------------------------------------+
Error: Only 13/16 tests passed深入研究这些测试的代码,它们似乎由于没有经过身份验证而失败(rest_availability、background_updates和loopback_requests)。例如,background_updates希望调用GET /wp-admin/site-health.php?health-check-test-wp_version_check=1,这是失败的,因为技术上我没有被登录到仪表板中。除了创建临时管理员并使用该管理员登录(这听起来是一个糟糕的解决方法)之外,是否有任何方法可以暂时使用WordPress进行身份验证,以便这些测试能够通过?
发布于 2019-12-10 09:22:42
默认情况下,WP-CLI以未经身份验证(注销)用户的身份执行每个命令。要以任何现有WordPress用户的身份执行命令,可以使用全局--user参数,该参数接受用户ID、登录或电子邮件地址。
$ wp nurse check --all --user=1在运行$ wp --help或$ wp COMMAND --help时,您将得到所有其他全局参数。
全局参数- user =设置WordPress用户。
https://wordpress.stackexchange.com/questions/354247
复制相似问题