• Resolved forgetme

    (@forgetme)


    When I clear my cache in WP Rocket it get the following errors in my debug log.

    Notice: Undefined index: REQUEST_METHOD in /home/forgetme/mstore.forgetmeknot.co/wp-content/plugins/wp-rest-cache/includes/api/class-endpoint-api.php on line 171

    Notice: Undefined index: REQUEST_METHOD in /home/forgetme/mstore.forgetmeknot.co/wp-content/plugins/wp-rest-cache/includes/api/class-endpoint-api.php on line 294

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter forgetme

    (@forgetme)

    Note that WP Rocket is cleared with a custom script that is called with webhook anytime I commit to my github repo.

    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @forgetme

    Thank you for using our plugin!

    I find it really strange you are getting these notices.

    First of all why would clearing the WP Rocket cache trigger a call to the WP REST API? Only a call to the WP REST API would run our code and only if the REQUEST_METHOD isn’t set it would cause this notice. So why a call to the API and why a call without a REQUEST_METHOD?

    Second, if you are getting these notices from our plugin, you should also be getting them from WordPress core. The code you are getting the notices from is triggered by the WordPress filter rest_pre_serve_request (see: https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-api/class-wp-rest-server.php#L463) Now if you look at that class from WordPress core, you can see that before invoking that filter they also use the REQUEST_METHOD (See: https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-api/class-wp-rest-server.php#L390).

    Unfortunately I do not have access to a copy of WP Rocket, so I cannot investigate what they are doing, but my guess is that they are the ones doing something wrong.

    Thread Starter forgetme

    (@forgetme)

    I can follow up with WP Rocket about this, but here is the exact calls being made to clear caches and preload all caches.

    
    // Clear WP Rocket cache.
    if ( function_exists( 'rocket_clean_domain' ) ) {
    	rocket_clean_domain();
    	echo ( "Cache Flushed <br><br>" );
    	error_log( "Cache Flushed \n" );
    }
    
    // Clear WP & Redis cache.
    if ( function_exists( 'wp_cache_flush' ) ) {
    	wp_cache_flush();
    	echo ( "Redis Flushed <br><br>" );
    	error_log( "Redis Flushed \n" );
    }
    
    // Preload WP Rocket cache.
    if ( function_exists( 'run_rocket_sitemap_preload' ) ) {
    	run_rocket_sitemap_preload();
    	echo ( "Starting Sitemap Pre-load" );
    	error_log( "Starting Sitemap Pre-load \n" );
    }
    Plugin Author Richard Korthuis

    (@rockfire)

    Well this code doesn’t tell me much, there isn’t anything wrong with it as far as I can see. And although I still can’t see their whole code I realize maybe I was a bit too quick with saying they are the ones doing something wrong. It can also be caused by some other plugin / code.

    But please do ask them if they see anything in their code that might cause this. I am curious to know what is causing this.

    Thread Starter forgetme

    (@forgetme)

    Just wanted to let you know whatever you fixed in 2021.2.1 around object caching appears to have resolved this issue as well. I’m no longer seeing the error when I clear my WP Rocket cache.

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Clearing WP Rocket Cache triggers Undefined index errors.’ is closed to new replies.