• Resolved mcarner5

    (@mcarner5)


    We have enabled Redis on our site so that we can take advantage of the speed increases. Unfortunately, this has caused some problems.

    We are using a plugin that takes advantage of the “wc_get_template_part” filter to output its content at the appropriate location on the product archive page. For some reason when Redis is enabled, this filter returns a null value to the plugin causing the area to be blank. This has some pretty bad problems such as the sort by box and pagination buttons disappearing completely. I’m able to fix this if I disable the plugin’s AJAX functions and revert to the default sortby/pagination.

    I have dove into the code trying to figure out why this happened and traced it to Redis. I’m unable to see where this null value is coming from, but it only occurs when it is enabled. I’ve spoken to Kinsta, our host that installed the Redis server (version 6.0.6) and they are unable to provide any support.

    Is there a way to disable caching of this filter? Is that even something that’s supposed to be happening? I can try and troubleshoot this issue but I don’t even know where to start. I’ve ruled out all other possibilities at this point.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Hey @mcarner5,

    Sorry to hear you’re having issues.

    WP Redis doesn’t cache the wc_get_template_part filter by default. Maybe WooCommerce or another plugin is doing this?

    If you track down which cache group it’s using, you can disable persistent caching for that group with wp_cache_add_non_persistent_groups()

    See https://github.com/pantheon-systems/wp-redis/#how-do-i-disable-the-persistent-object-cache-for-a-bad-actor

    Hope this helps!

    Thread Starter mcarner5

    (@mcarner5)

    Daniel, thank you for the response! Originally I thought it may be some sort of plugin conflict but could only recreate the issue when Redis was enabled and running, regardless of what else was enabled.

    Any idea how I could go about tracking down which cache group? Would I need to turn Redis on and then use the CLI to find it?

    Once I find it, is that a command I can just put in functions.php?

    • This reply was modified 3 years, 6 months ago by mcarner5.
    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Daniel, thank you for the response! Originally I thought it may be some sort of plugin conflict but could only recreate the issue when Redis was enabled and running, regardless of what else was enabled.

    One thing you could test is whether the problem reproduces with another Redis object cache drop-in. This would either prove or disprove that the problem is associated with WP Redis.

    Any idea how I could go about tracking down which cache group? Would I need to turn Redis on and then use the CLI to find it?

    Unfortunately, this is the hard part. I’d start by searching your codebase for wc_get_template_part to see other functions that might be hooked on to the filter. If this approach leads to a dead end, then it would require reviewing the likely candidates (e.g. WooCommerce-related plugins, etc.).

    Although, if you’ve already deactivated all of your plugins and the problem reproduces, maybe it’s an issue with your theme? Or whatever custom code you’ve written that’s experiencing the problem?

    Once I find it, is that a command I can just put in functions.php?

    Yes, you’ll drop this function in your functions.php once you identify the group: wp_cache_add_non_persistent_groups( array( 'group-name' ) );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wc_get_template_part returning null when WP Redis is enabled’ is closed to new replies.