WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] [Plugin: Yet Another Related Posts Plugin] No related posts When Post Published or Updated (38 posts)

  1. Todd Lahman
    Member
    Posted 2 years 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 2 years 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. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 2 years ago #

    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 2 years 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 2 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years 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 years ago #

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

  15. Todd Lahman
    Member
    Posted 2 years 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 years ago #

    Here is the W3TC 0.9.2.4 Object-cache.php

    http://snipt.org/ujEc3

  17. dentvii
    Member
    Posted 2 years 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 years 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 years 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 years 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 2 years 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 2 years 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 2 years 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.

  24. dentvii
    Member
    Posted 2 years ago #

    Even running with no cache the plugin still runs and yet it doesn't show any results!
    You can guess in my server graph when were the two moments I turned on YARPP with no cache.
    http://imgur.com/ZhKkS

    Can't wait to see your work Todd.

  25. canalblues
    Member
    Posted 2 years ago #

    This plugin is not working, some related posts shows and some not. RSS 'related posts' lost too.

    This plugin seems abandoned.

  26. dentvii
    Member
    Posted 2 years ago #

    My Related posts in the RSS is working canal blues. Yet most of the wordpress related post don't because of some bad cache behavior.
    I recommend nRelate meanwhile Todd doesn't releases a similar plugin but up to date.

  27. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for all the details here. @dentvil: if you're using an aggressive page cache and/or query cache, bypassing the YARPP cache is indeed reasonable. I assume you figured out how you can specify this using YARPP_CACHE_TYPE?

    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')); ?>)

    It does cache this, because it's actually smarter than just not caching if you specify options. Only options which change the calculation of the algorithm make it bypass the cache. If it's just limiting the number of results or using another template, it'll still cache the regular results.

    @toddlahman, thanks for your detailed suggestions for fixing this. I hope to integrate your changes quickly. The link you had before seems down. Could you summarize what you changed in those three files?

    Finally, for all of you: there was an independent issue with non-MyISAM tables, which may be affecting some of you. This is fixed in the latest dev version. I encourage you to check it out: http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.zip

  28. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    I looked through all my code to figure out what all changes are necessary to fix the incompatibility with object caching, and I've made the changes in 3.5.2b3. Please test it and let me know if it fixes your issues. Hopefully it does. Thanks again!

    http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.3.5.2b3.zip

  29. dentvii
    Member
    Posted 1 year ago #

    Thanks for the effort mitcho. I have tried and it seems the issue is still there. I can reproduce it by flushing the cache with experiments, clearing all caches with w3tc and then trying to display the page as non-admin.
    It helps, but doesn't solve entirely, if I flush YARPPs cache, build it, then clear the w3tc cache. This way, most posts have related articles, but some don't (random, no pattern recognized).

    What apparently has been fixed it the call for both related, where one would show related posts and another wouldn't. Here is a page in which you can check it out (right sidebar and before breadcrumbs Como usar Google+.

    Thanks for sharing and trying anyway.

  30. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    @dentvii, so previously having two displays was broken for you? And that's fixed now? Well, that's an improvement at least. If that's true, and there are other bugs which have been fixed, so I may push out this release. As long as it hasn't made anything worse. :)

    I'm going to have to set up an environment with W3TC with the appropriate options. Do you just use W3TC or is W3TC interacting with something like XCache or APC or memcached?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic