All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: Strange bug when adding 'highest rated' code outside loop!  (Read 4727 times)

0 Members and 1 Guest are viewing this topic.

Offline Sheamus

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hi

WordPress Version: 2.3.3
Theme: IAMWW w2 DnD 0.85
Blog URL: http://www.actionmoviemania.com/
Problem Plugin Name And Version: WP Post Ratings 1.20

Great script - worked perfectly out of the box, except this odd little bug!

I'm setting up a website that reviews action movies, notably the classic ones from the 1980s-1990s. I wanted a feature that let users add their own ratings, and this is where your script comes in! :)

Works great, except this oddity. I've started a post that will eventually show the Top 100 user reviews on the site:

http://www.actionmoviemania.com/2008/03/27/the-user-top-100/

I've executed the PHP in this post using the well-known EXEC-PHP plugin (http://bluesome.net/post/2005/08/18/50/). It's worked, but oddly, it's also added the Top 100 page *itself* to the 'ratings' list, too, even though no [rating] command exists on that page, nor is it in any way ratable! :D

It's also added it to the Top 10 highest-rated widget that displays on the sidebar, so the bug *does* seem to be in your plugin, as opposed to anywhere else, although I may be quite wrong! :)

This is the code I've used:

Code: [Select]
<?php if (function_exists('get_highest_rated')): ?>
   <ul>
      <?php get_highest_rated('both',100); ?>
   </ul>
<?php endif; ?>

It's an odd little error but obviously not something I want displayed on my rankings page! :D

Any help appreciated.

Cheers,
Sheamus

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #1 on: 27 March 2008, 17:27 »
because you use 'both', so it will include ALL pages(including itself). It is not a bug.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Sheamus

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #2 on: 27 March 2008, 19:36 »
Yeah, that doesn't explain the widget error, though, which is producing the same output (despite being set to post). The 'Most Rated' widget has the same problem.

Replacing 'both' with 'post' (in a post), as per your advice, produces an identical result.

Indeed, just doing a new 'test' post adds this to the rating output, even though it doesn't have the [rating] code included.

http://www.actionmoviemania.com/2008/03/17/test/

I haven't added any code to the loop as I don't want it on every page - just review pages, hence using the [rating] tag as suggested. But somehow it *is* being added to every new page, even if it's in a non-rateable way.

Cheers for your help. :)

NB: I've removed the posts I linked above (from my site) in my first post in this forum.

EDIT: Simply *editing* a page adds it to the ratings output list as well. Clearly some kind of function is being inserted when one does anything in the edit window but I've searched through all my theme files and can't find the rating function anywhere. Most perplexing.  :(

EDIT #2: What I've just noticed is that when making a new post, the ratings function is *not* included in the 'custom fields' area, but once posted, it's there when you do an edit. Deleting all the ratings custom fields does not remove the post itself from the output (in the top X).

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #3 on: 28 March 2008, 03:59 »
all the 3 ratings, users, score and average will be created upon publishing the post. It will appear in your top rated because the rated post has not enough posts to fill up the top 100 position and hence it will appear. In the new version, I have set a minimum number of posts before it appears.

I think you got it wrong, your Top 100 seems to be a post instead of a page as you stated on top of the post. so it will produce the same results if you change it from both to post


++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Sheamus

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #4 on: 28 March 2008, 10:43 »
all the 3 ratings, users, score and average will be created upon publishing the post. It will appear in your top rated because the rated post has not enough posts to fill up the top 100 position and hence it will appear. In the new version, I have set a minimum number of posts before it appears.

So if I install the latest version it should fix my problem, yes?

Otherwise, I must admit I'm a bit confused as to your reply, principally because if the widget itself is giving this problem, and every new post I make automatically gets added to the widget's output (and the top 100 post), even though your function is not in my loop and I'm leaving out the [ratings] command, I'm not sure exactly what it is I've done wrong.

My gut feeling is that somehow it's gotten into the loop, because otherwise I don't see why each new post would be getting added to the ratings database.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #5 on: 28 March 2008, 16:38 »
It does not matter whether you are using [ratings] or not as every post you create, its default value will be 0 for the ratings users, score and average.

Your top 100 rated post will just display the top 100 rated post regardless or not where the value is 0. As your post ratings are limited (due to there is not more than 100 posts that is rated at least once), it will still display the 0 ratings post.

No idea whether you got me.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Sheamus

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #6 on: 28 March 2008, 17:40 »
It does not matter whether you are using [ratings] or not as every post you create, its default value will be 0 for the ratings users, score and average.

Your top 100 rated post will just display the top 100 rated post regardless or not where the value is 0. As your post ratings are limited (due to there is not more than 100 posts that is rated at least once), it will still display the 0 ratings post.

No idea whether you got me.

Right, so effectively I need to not have a top 100 page until I actually *have* 100 reviews, yeah?

And same goes for the widget - 'cause it's looking for ten reviews, yeah?

I think that's what you mean. :)

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Strange bug when adding 'highest rated' code outside loop!
« Reply #7 on: 29 March 2008, 08:18 »
AMMO: yeap =D sorry about my English, Singaporean English is quite broken.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.