• Resolved johnferz

    (@johnferz)


    Dear all!

    function wprc_add_imserv_compositor_endpoint( $allowed_endpoints ) {

    if ( ! isset( $allowed_endpoints[ 'wp/v2' ] ) || ! in_array( 'compositor_rest_api', $allowed_endpoints[ 'wp/v2' ] ) ) {
    $allowed_endpoints[ 'wp/v2' ][] = 'compositor_rest_api';
    }
    return $allowed_endpoints;
    }
    add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_imserv_compositor_endpoint', 10, 1);

    This code doesn’t work for us. Rest requests are not caching.
    Using basic settings after installation. Wp native rest api requests caching works.

    The page I need help with: [log in to see the link]

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

    (@johnferz)

    Also there are no entry of unknown cached objects.

    Thread Starter johnferz

    (@johnferz)

    Nothing in logs.

    Thread Starter johnferz

    (@johnferz)

    Please help to fix.

    Thread Starter johnferz

    (@johnferz)

    Also please explain this error on custom endpoint caching.

    Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, string given in /home/i/imstest1/imstest1.ru/public_html/wp-content/plugins/wp-rest-cache/includes/caching/class-caching.php:936 Stack trace: #0 /home/i/imstest1/imstest1.ru/public_html/wp-content/plugins/wp-rest-cache/includes/caching/class-caching.php(936): array_key_exists(‘id’, ‘\n{“filterHtml”:…’) #1 /home/i/imstest1/imstest1.ru/public_html/wp-content/plugins/wp-rest-cache/includes/caching/class-caching.php(815): WP_Rest_Cache_Plugin\Includes\Caching\Caching->determine_object_type(Array) #2 /home/i/imstest1/imstest1.ru/public_html/wp-content/plugins/wp-rest-cache/includes/caching/class-caching.php(173): WP_Rest_Cache_Plugin\Includes\Caching\Caching->register_endpoint_cache(’70ae2e6ace25eb5…’, Array, ‘/wp-json/wp/v2/…’, Array, ‘GET’) #3 /home/i/imstest1/imstest1.ru/public_html/wp-content/plugins/wp-rest-cache/includes/api/class-endpoint-api.php(275): WP_Rest_Cache_Plugin\Includes\Caching\Caching->set_cache(’70ae2e6ace25eb5…’, Array, ‘endpoint’, ‘/wp-json/wp/v2/…’, ”, Array, ‘GET’) #4 [internal function]: WP_Rest_Cache_Plugin\Includes\API\Endpoint_Api->save_cache(‘\n{“filterHtml”:…’) #5 /home/i/imstest1/imstest1.ru/public_html/wp-includes/class-wp-hook.php(310): call_user_func_array(Array, Array) #6 /home/i/imstest1/imstest1.ru/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(‘\n{“filterHtml”:…’, Array) #7 /home/i/imstest1/imstest1.ru/public_html/wp-includes/rest-api/class-wp-rest-server.php(517): apply_filters(‘rest_pre_echo_r…’, ‘\n{“filterHtml”:…’, Object(WP_REST_Server), Object(WP_REST_Request)) #8 /home/i/imstest1/imstest1.ru/public_html/wp-includes/rest-api.php(410): WP_REST_Server->serve_request(‘/wp/v2/composit…’) #9 [internal function]: rest_api_loaded(Object(WP)) #10 /home/i/imstest1/imstest1.ru/public_html/wp-includes/class-wp-hook.php(308): call_user_func_array(‘rest_api_loaded’, Array) #11 /home/i/imstest1/imstest1.ru/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #12 /home/i/imstest1/imstest1.ru/public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array) #13 /home/i/imstest1/imstest1.ru/public_html/wp-includes/class-wp.php(399): do_action_ref_array(‘parse_request’, Array) #14 /home/i/imstest1/imstest1.ru/public_html/wp-includes/class-wp.php(780): WP->parse_request(”) #15 /home/i/imstest1/imstest1.ru/public_html/wp-includes/functions.php(1334): WP->main(”) #16 /home/i/imstest1/imstest1.ru/public_html/wp-blog-header.php(16): wp() #17 /home/i/imstest1/imstest1.ru/public_html/index.php(17): require(‘/home/i/imstest…’) #18 {main} thrown in /home/i/imstest1/imstest1.ru/public_html/wp-content/plugins/wp-rest-cache/includes/caching/class-caching.php on line 936

    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @johnferz

    Thank you for using our plugin!

    I don’t see anything wrong with the code from your first post, it should work just fine. The fact that you are getting the error in your last post and the error that is now visible on your?rest?endpoint also suggests that our code is trying to?cache?it.The reason you are getting the error from your last post probably has to do with the changes you described in the posts you have since deleted (I did receive a mail about them, so I was able to read them). I suspect that your changes caused an incorrect?cache?entry and that is where the error is coming from. I would suggest you delete all?cache?records, so the invalid?caches?get deleted. To do so visit Settings >?WP?REST?Cache?> Clear?Caches?and be sure to check the “Delete all?caches”.
    The current fatal error on your endpoint has to do with incorrect code, where you use $this. Look at that code and fix the error.

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