Forums

Yet Another Related Posts Plugin
No related posts When Post Published or Updated (23 posts)

  1. Todd Lahman
    Member
    Posted 4 months ago #

    When publishing a new post, or updating an existing published post, there are "No related posts."

    I am using Memcached, and Batcache. When I stop and restart Memcached the related posts appear as if they existed already.

    Perhaps I need an option to force related posts to clear and recalculate when publishing or updating to force Memcached to update that post ID.

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. Todd Lahman
    Member
    Posted 3 months ago #

    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.

  3. 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.

  4. Todd Lahman
    Member
    Posted 3 weeks ago #

    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.

    http://ngurl.me/yarpp-cache

  5. Todd Lahman
    Member
    Posted 3 weeks ago #

    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.

    http://ngurl.me/yarpp-cache

  6. Todd Lahman
    Member
    Posted 2 weeks ago #

    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.

  7. Todd Lahman
    Member
    Posted 2 weeks ago #

    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:

    http://ngurl.me/yarpp-cache

  8. dentvii
    Member
    Posted 2 weeks ago #

    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.

  9. Todd Lahman
    Member
    Posted 2 weeks ago #

    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.

  10. dentvii
    Member
    Posted 2 weeks ago #

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

    Why are you using such an old version?

  11. Todd Lahman
    Member
    Posted 2 weeks ago #

    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.

  12. dentvii
    Member
    Posted 2 weeks ago #

    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.

  13. Todd Lahman
    Member
    Posted 2 weeks ago #

    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?

  14. dentvii
    Member
    Posted 2 weeks ago #

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

  15. Todd Lahman
    Member
    Posted 2 weeks ago #

    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?

  16. dentvii
    Member
    Posted 2 weeks ago #

    Here is the W3TC 0.9.2.4 Object-cache.php

    http://snipt.org/ujEc3

  17. dentvii
    Member
    Posted 2 weeks ago #

    This is a page with no related posts however, if the YARPP is flushed, there will be related posts, as threshold is at 3, so all related PDF articles would come up. http://www.vejaisso.com/como-extrair-imagens-fotos-de-pdf-copiar-imagens-pdf-adobe-reader-download/

  18. Todd Lahman
    Member
    Posted 2 weeks ago #

    W3TC uses the cache.php file included with WordPress, which is poor compared to Ryan Boren's plugin.

    I was solving a related post refresh problem in the post loop, but you are using the sidebar widget, so the solution is different. I may have solved that problem, but I'll need you to test it to be sure.

    In the cache-postmeta.php file inside the clear function I added the following lines starting at line 152:

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

    I also updated the fixed file link below to now include class-cache.php, cache-tables.php, and cache-postmeta.php. This fix is for YARPP Version 3.5.1.

    http://ngurl.me/yarpp-cache

    Let me know if this works for you.

  19. dentvii
    Member
    Posted 2 weeks ago #

    Nop, still no luck. The test page with the no related posts (http://www.vejaisso.com/como-extrair-imagens-fotos-de-pdf-copiar-imagens-pdf-adobe-reader-download/) still doesn't show no results.
    What I find really amusing is that on Mitcho's slides he says whenever Yarpp is called other than with the template, those calls are not cached. Then why the related at the bottom of the post doesn't show up, as they are called through custom code? (this is the call <?php if (function_exists('related_posts'))related_posts(array('limit' => 2,'template'=> 'yarpp-fim-post.php')); ?>)

  20. Todd Lahman
    Member
    Posted 2 weeks ago #

    I will have to look at this later to see if I can hunt down and test the sidebar widget code to refresh it. I'll post the solution when it is ready.

  21. dentvii
    Member
    Posted 5 days ago #

    My solution at the moment is to bypass the cache of YARPP and let W3TC and memcache to cache the DB queries. Certainly not the best solution, but yet, it is working.

  22. Todd Lahman
    Member
    Posted 5 days ago #

    I've stopped using YARPP altogether because it adds a FULLTEXT KEY to the posts table if the storage engine is MyISAM. MySQL now uses InnoDB as the default storage engine, because it is so much faster and more efficient, but it doesn't allow for the inefficient FULLTEXT KEY to be used. Since I have switched everything over to InnoDB I am writing a new related posts plugin that will replicate the great results YARPP gets, without the horrible overhead, issues with the cache, and can be used with either the InnoDB or MyISAM storage engine.

    I will only be releasing the new plugin on my blog when it is completed.

  23. dentvii
    Member
    Posted 4 days ago #

    That is awesome, looking forward to see your plugin =D
    nRelate is also a great inspiration for many blogs, as it provides really awesome customization and outsources the relatedness.

Reply

You must log in to post.

About this Plugin

About this Topic