Viewing 15 replies - 1 through 15 (of 37 total)
  • Thread Starter Todd Lahman

    (@toddlahman)

    I’ve looked through the plugin code, and can’t find an approach that will fix this problem, so I will suggest an enhancement in another thread.

    Hi Todd—I don’t think I saw the other thread for the enhancement. YARPP uses a caching abstraction object (all subclasses of YARPP_Cache) so I would encourage you to try building a Memcached version. I suggest you do this by copying YARPP_Cache_Postmeta as a base. Please post or email me if you have success, and I’d be happy to include it in a future version.

    Thread Starter Todd Lahman

    (@toddlahman)

    Hi Michael,

    I have a solution, and it was an easy fix. In the class-cache.php file on line 90 of the save_post function I added:

    wp_cache_delete('is_cached_'.$post_ID, 'yarpp');

    Now when a new post is saved, or an existing post is updated, the related posts will also be refreshed in Memcached for that post.

    Below is a link to the class-cache.php file with the modification.

    If you could add this to the next update I would greatly appreciate it.

    https://ngurl.me/yarpp-cache

    Thread Starter Todd Lahman

    (@toddlahman)

    I added a check to make sure WordPress is configured to use caching before refreshing the related post cache. Here’s the code:

    if ( WP_CACHE ) {
    	wp_cache_delete('is_cached_'.$post_ID, 'yarpp');
    }

    Below is a link to the class-cache.php file with the modification.

    https://ngurl.me/yarpp-cache

    Thread Starter Todd Lahman

    (@toddlahman)

    The problem I am still having with this is, when the cache is cleared for that single post it does not also clear the related posts. When the single post cache is cleared the related posts return “No related posts found,” which means I need to clear those related posts from the cache as well, but I am not sure how to find their $post_id, and run a foreach to clear them from the cache. I thought I could use:

    $peers = $this->related(null, $post_ID);

    to grab the ids, but that didn’t work, so I must be missing something. Maybe you could help me finish this part since you now your plugin better than I do.

    Thread Starter Todd Lahman

    (@toddlahman)

    Okay, finally got this fixed. Please include in your next update.

    In addition to the code I added to the class-cache.php file above, I also added the following code in the cache-tables.php file inside the clear function:

    foreach ( $reference_ID as $pid ) {
    	wp_cache_delete('is_cached_'.$pid, 'yarpp');
    }

    The two files can be downloaded using the link below for YARPP version 1.5.4:

    https://ngurl.me/yarpp-cache

    Awesome Todd, I’ll try it myself as well.
    I am using WP 3.3.1, YARPP 3.5.4b Beta and YARPP Experiments. Running on nginx with memcached and w3tc.

    I am having a similar issue. Without a post being updated or a new post being added, I would once encounter a page which I knew it had many related posts and the YARPP not showing any. So a refresh in the cache would fix it. I’ll try your fix and let you know.

    Thread Starter Todd Lahman

    (@toddlahman)

    The two files I made available to download with the code changes will only work for sure with YARPP version 1.5.4. Since your are using a different version you will need to make the code changes manually in class-cache.php and cache-tables.php, or downgrade your version to 1.5.4 and replace the two files from my download.

    3.5.4b with changes by Todd. Not fully tested.
    https://snipt.org/ujDj6
    https://snipt.org/ujEa6

    Why are you using such an old version?

    Thread Starter Todd Lahman

    (@toddlahman)

    Oops. I am so glad you pointed that out. I looked at my installed plugins and wrote version 1.5.4 which was actually for YOURLS: WordPress to Twitter. Right above that is Yet Another Related Posts Plugin, so the version of YARPP I am using is actually Version 3.5.1, and so the changes I made are for YARPP Version 3.5.1.

    The changes in your links above look like they should work correctly.

    Didn’t work. I am still seeing no related posts when there are related articles. Only after flushing with experiments I can see that they indeed exist.

    Must I notice that I have two points in my code in which the YARPP is called, first an non cached at the end of the post and then on the sidebar at the top, using the plugin itself.

    Thread Starter Todd Lahman

    (@toddlahman)

    My setup uses Batcache storing and serving posts from Memcache. If you are using W3TC to serve pages from disk, then the changes I made will have no effect.

    I haven’t looked at the sidebar widget yet, so I’ll have to take a look at that later.

    How is your W3TC configured to cache and serve posts?

    My W3TC serves Page, object and database from Memcached as well.

    Thread Starter Todd Lahman

    (@toddlahman)

    W3TC has it’s own custom object-cache.php file. I use the plugin from Ryan Boren. Can you post the contents of that file on snipt.org?

    Here is the W3TC 0.9.2.4 Object-cache.php

    https://snipt.org/ujEc3

Viewing 15 replies - 1 through 15 (of 37 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] No related posts When Post Published or Updated’ is closed to new replies.