Plugin causes fatal error when clearing cache
-
Plugin version: 5.7.12
Error message: PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in public_html/wp-content/plugins/sg-cachepress/core/DNS/Cloudflare.php on line 155
This errors occurs sometimes when crearing cache.
This plugin uses WordPress HTTP API (like wp_remote_get() functions) to make HTTP requests. When request fails, plugin doesn’t handle WP_Error. Here’s the code that causes error:if ( empty( $response[‘result’][0][‘id’] ) ) {
It should be like this:
if ( is_wp_error($response) || empty( $response[‘result’][0][‘id’] ) ) {According to documentation https://developer.wordpress.org/reference/functions/wp_remote_get/, WP_Error is returned when function fails.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.