WordPress.org

Ready to get started?Download WordPress

Forums

Popularity Contest Plugin and WordPress, 2.1 (24 posts)

  1. dylan
    Member
    Posted 8 years ago #

    I am using the Popularity Contest Plugin by Alex King and wordpress, 2.1. Upon saving a post, i get the following error.

    Warning: Invalid argument supplied for foreach() in wp-content/plugins/popularity-contest.php on line 1295 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3

  2. Alex King
    Member
    Posted 8 years ago #

    I hope to have time to find out what needs fixing for 2.x and get it fixed soon.

  3. Alex King
    Member
    Posted 8 years ago #

    I just got latest WP out of SVN and I can't seem to reproduce this problem. Additionally, looking at the code in that area in Popularity Contest, I can't see how an error condition could occur to generate that warning.

    Are you using version 1.1 of Popularity Contest?

  4. morlock
    Member
    Posted 8 years ago #

    Yes, the latest version available (1.1) from your site. I have tried your version and this version and both returns the same error.

  5. Alex King
    Member
    Posted 8 years ago #

    If you have other plugins installed, have you tried disabling them and seeing if the error persists?

    I'm willing to take a look at this on your server - e-mail me your FTP/SFTP login and a login to your WP install if you want me to take a look.

  6. cavemonkey50
    Member
    Posted 8 years ago #

    Alex, not to hijack this thread, but Popularity Content isn't recording visits on WordPress 2.0.x. I'm not getting any errors, it's just not recording anything. I just wanted to make you aware of this issue.

  7. Alex King
    Member
    Posted 8 years ago #

    Very interesting.

    I just got latest from WP SVN and Popularity Contest SVN on wp-plugins.org. I ran upgrade.php on my existing database - hit the site a few times - everything worked perfectly.

    Then I dropped the database and did a clean install in a new database. For some reason, now that there is a clean install, my 'is_admin_page' function (which checks for the existance of the 'check_admin_referer' function) now returns true, causing the plugin not to record any views.

    The is_admin function (added in 2.x I believe) seems to accomplish the same goal as my 'is_admin_page' function, so I've added a patch to use that if it's available.

    What I really don't understand though, it how the database change (upgraded DB vs. clean 2.x DB) made any difference. Also, why 'check_admin_referer' is active on non-admin pages now is beyond me.

    Anyway - new version checked in to wp-plugins.org.

  8. cavemonkey50
    Member
    Posted 8 years ago #

    Alex, I just grabbed the latest version. I'll let you know if its start recording hits.

    Now just to make things even more interesting for you, I have an upgraded DB. I've used the same database since WordPress 1.2x, so your theory of a clean install doesn't hold up.

    The only thing I can possibly think of is 'check_admin_referer' now reports if the post is created by an admin. The reason why I say that is because I have some older pages that I imported from MT before I used WordPress. Those posts were not imported as the admin user; I had to create a new user to import them. Those pages were tracking hits, leading me to believe that the 'check_admin_referer' is now reporting if the admin created the page.

  9. tedfox
    Member
    Posted 8 years ago #

    heh. the shortstat plugin and popularity plugin i was using ran into problems, and i discovered it's the same reason. and same solution. so i'll just copy and paste from the other thread

    http://wordpress.org/support/topic/56700?replies=9

    Okay, I fixed the wp-shortstat problem. Here's the deal: in order to avoid recording admin page hits, the plugin was testing whether or not a function named "check_admin_referer" was defined. That worked until WP 2.0.1, when that function moved from the admin functions to pluggable functions, meaning it's now always defined.

    so swap
    if (function_exists('check_admin_referer')) {
    for
    if (function_exists('user_can_access_admin_page')) {

  10. dimitrisp
    Member
    Posted 8 years ago #

    I applied the latest version from trunk and it seems to be working fine now!

  11. dylan
    Member
    Posted 8 years ago #

    I found the latest version of the plugin on the WP Plugins Site, and it seems to be working for me. Yay!

  12. elyonline
    Member
    Posted 8 years ago #

    Hmmm I am running 2.01 and donot have the <?php akpc_the_popularity(); ? in my loop but each post is showing a popularity.

    I don't want to show popularity on my pages, How do I remove this from my pages.

    Thanks

  13. cavemonkey50
    Member
    Posted 8 years ago #

    elyonline, there is a variable you need to change to a 0 in the very beginning of the file to prevent the popularity information being shown.

    Alex, after giving it some time, I can confirm that the latest update is indeed logging hits.

  14. elyonline
    Member
    Posted 8 years ago #

    Ah yes that was it, forgot after I downloaded latest version. Thanks

  15. tedfox
    Member
    Posted 8 years ago #

    another side track. is it possible to hack this such that popularity of pages are counted too??

    I run a blog with extensive pages..... so it'll be nice if someone could tell me how to change things

  16. cavemonkey50
    Member
    Posted 8 years ago #

  17. Ronny
    Member
    Posted 8 years ago #

    hey great plugin.
    just wanted to know if there's anyway to make certain posts "exempt" from the plugin contest counter?

    you might be wondering what situation would require something like that. well, i have a "sticky" annoucement posts that stay at the top of the blog for all visitors, and i'm trying to take those completely out of the popularity contest because they aren't really much content, and also they are bound to get high popularity scores simply because they are "stuck" to the top of the blog.

    thanks!
    Ronny.

  18. Alex King
    Member
    Posted 8 years ago #

    That's an interesting problem. One "solution" would be to put the content of that post in your theme rather than havng it be retrieved from the database each time. Another would be to create your own copy of the_content() that doesn't have the hooks that PC uses. Another would be to create an "exclude" list in PC that could be set to ignore certain posts.

    Of course, the purist in me says, "People are viewing that content, it *should* be counted." ;)

  19. Ovidiu
    Member
    Posted 7 years ago #

    ok, here comes another problem:

    I have been battling around with the problem that after posting, editing or deleting a post from the admin menue I always got an error:

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3

    I have just now disabled all plugins and posted after each disabling and found out if I disabled popularity contest my post, edit and delete worked again.

    is this an issue of the plugin or maybe an interaction with some other plugin?

    my wp version is 2.0.4

  20. Ovidiu
    Member
    Posted 7 years ago #

    oh, found out is is still interacting with google sitemaps...
    any solution to this?

  21. Mike Koepke
    Member
    Posted 7 years ago #

    I did some troubleshooting and fixed the error and warning. Starting at line 1298 of the 1.2b3 file:

    foreach ((array)$ak_posts as $post) {
    $ids[] = $post->ID;
    }

    $result = mysql_query("
    SELECT post_id, total
    FROM $wpdb->ak_popularity
    WHERE post_id IN ('". implode("','", $ids). "')
    ") or die(mysql_error());

    Basically the $ak_posts needed to be casted to an array and SQL syntax for the IN qualifier needed signle quotes added.

    Mike

  22. fortyfoxes
    Member
    Posted 7 years ago #

  23. CSSgirl
    Member
    Posted 7 years ago #

    Hi -

    I have a fresh WordPress install (latest version) and added in the popularity contest plugin. I downloaded both versions (the 1.1 release from Alex's site and the 1.0 version referenced above, available on the wp-plugins site) and both ways the plugin isn't recording any views at all. What can I do to resolve this?

    Thanks,
    Lindsey

  24. CSSgirl
    Member
    Posted 7 years ago #

    Huh. On a whim I decided to install that Thunderguy Pop. Contest plugin just for the heck of it, although I really don't want to track pages - and it does work for that...

    Any word on releasing the orginal Pop. Contest plugin so it's compatible with the latest WP?

    Best,
    Lindsey

    EDIT: Ok, wait it's not totally working - I have it set to display the 5 most popular articles and it doesn't show anything :( All it says is (none)

Topic Closed

This topic has been closed to new replies.

About this Topic