Fixing comments in Wordpress while running Spam Karma and WP-cache
27 January 2008 by jimUPDATE: What I have outlined below does NOT fix the problem. I posted a comment to Priv's blog below where I initially found this to let him know I could not get his fix to work. When I submitted my comment to his site it was invisible to me, but it was in the RSS comment feed and could be seen by another browser. But the browser I had submitted the comment from could not see the comment.
I was tearing my hair out trying to figure out why comments were not appearing on posts immediately. I think I've patched it all togther:
1. Download this file: http://priv.dreamhosters.com/wp-things/sk2_wp_cache_plugin.zip
and extract and drop the php into sk2_plugins directory.
2. This next set of modifications was found at http://mu.wordpress.org/forums/topic.php?id=2296&page=2&replies=45
here is the fix for the payload SK2 plugin to still work with WP-Cache. This also solves problems that may have occurred with the stopwatch plugin which uses the time embedded in the payload plugin (which as a side note, breaks the plugins independance, but well).
This also gives a good example of how to use the mfunc thingy :
In sk2/sk2_payload_plugin.php, replace the form_insert function with:
function form_insert($post_ID)
{
$seed = $this->get_option_value('secret_seed');
if (empty ($seed))
{
$seed = sk2_rand_str(10);
$this->set_option_value('secret_seed', $seed);
$this->log_msg(__("Resetting secret seed to: $seed."), 5);
}
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
//echo (""); // debug
$payload = md5($time . $seed . $ip . $post_ID);
echo "
";
}
note the added mfunc tags. The seed and postids are passed as parameters so that the replacement function doesn't have to fetch them. WP-Cache is smart enough not to output those parameters in the HTML file received by the client, which makes you safe from seeing the seed hijacked.
Now, add this function to wp-cache-phase1.php :
function cached_sk2_javascript_payload($seed,$postid) {
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$payload = md5($time . $seed . $ip . $postid);
echo "
";
echo "
";
echo "
";
}
this way, time and IP won't be cached and the stopwatch+payload plugins will still work. The javascript_plugin only computes some math stuff so it's not broken by WP-cache.
3. delete old cache before you
4. Turn off ‘encrypted payload’ check in sk2
5. I then disable WP-Cache and deactivate both SK2 and WP-cache and re-active them. Not certain if this is needed but it can't hurt. Then enable WP-cache.
Reference URLs:
http://mu.wordpress.org/forums/topic.php?id=2296&page=2&replies=45
http://privism.org/blog/archives/12
wpcache-and-spam-preventers-like-spam-karma-21-will-never-work-in-harmony