WordPress.org

Ready to get started?Download WordPress

Forums

Need WP-Cache + Democracy 2 Help (6 posts)

  1. I'm trying to get the two to play nice, but they won't. Seems when WP-Cache is pulling the page from the cache, jal_democracy() is not defined, i.e. the plugin doesn't get loaded apparently. Any clue as to what I should do? Or am I stuck to getting whatever loads initially being cached?

    This is what I have in the theme:

    <!--mfunc jal_democracy() -->
    <?php jal_democracy(); ?>
    <!--/mfunc-->

    Works fine the first time (when it's not cached), but when I refresh the page (and it gets pulled from the cache), I get function not defined.

  2. Okay, this problem has nothing to do with Democracy. The problem is completely WP-Cache related. Seems it doesn't load up plugins when pulling a page from the cache. I just wrote a super simple plugin with a function that echo's the time and it breaks after a page refresh (undefined function). Damn.

    Wonder if include()'ing the plugin's file will work or not, i.e. if get_option() and such is loaded at the time WP-Cache runs. My guess is it's not and that won't work. Grr.

  3. I've tried everything. I'm totally outta ideas. :/

  4. Okay, I finally got it working... sorta.

    What I ended up doing was giving up on keeping it dynamic and instead made the goal of always having the form load up when the page is loaded no matter what. That means the vote form itself gets cached and then people can use it to vote and/or view the results via AJAX (which are cache independent).

    To get the form to display even if a person had voted before (previously if a person had voted, it'd display the results off the bat), I did a little hack in my theme.

    That alone works, but I went a step further. By default, Democracy sets a cookie when you vote. This is a problem because in order to show you the right page, WP-Cache takes cookies into account. For example, if you (an average user) view my site, you'll get a different page (and cache file) than me because I have a cookie that says I'm logged in.

    Now of course many, many people will have a cookie that says they have voted in poll A, but the problem occurs when we move on to new polls. There would need to be a cache for people who have a cookie for poll A, a cache for people who have a cookie for B, and a cache for people who voted for both. And the problem gets worse with the more polls that are made.

    So, I removed the line that sets the cookie and left duplicate vote protection to just IP logging alone. Of course this can lead to problems for those sharing an IP (can't vote) or those with a dynamic IP (can vote more than once), but I think the problems should be minimal.

    Anyway, just thought I'd share what I ended up doing and you can see it in action at FinalGear.com.

  5. solutionsphp
    Member
    Posted 7 years ago #

    Thanks for posting your solution! I'm looking to use both wp-cache and Democracy on my site as well. I was wondering if you might clarify the steps required for this fix?

    I tried replacing the default Democracy tag in template with the code in your pastebin. You mentioned that "this alone works", however I still get the "Warning: semget() failed for key 0x152b:" error on posts and pages (I only display Democracy on the home page).

    Next, where is the line that needs to be removed, re: the cookie?

    Thanks in advance!

  6. solutionsphp
    Member
    Posted 7 years ago #

    The solution to my problem with the semget() failed error was to enable flock in wp-cache-config.php.

Topic Closed

This topic has been closed to new replies.

About this Topic