Support » Plugin: SG Optimizer » Plugin causes fatal error when clearing cache

  • Resolved ovidijusk

    (@ovidijusk)


    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)
  • Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hey there @ovidijusk,

    Is it possible to provide a site URL, so we can check the issue? Also, the exact steps to recreate the issue will be highly appreciated (like go on that specific page, do that action, click that button).

    Kind regards,
    Stoyan

    Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Marking as resolved due to no reply.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.