Sag Rising

Notes to Myself

The Humble var_dump

Posted by Richard Cockrum on June 3, 2008

There are a several of plugins available for Habari to deal with spam. Most people seem to prefer the ones that use outside services such as Aksimet and Defensio. I don't like relying on outside services so I rely on the simple spamchecker plugin that comes with Habari and the simple blacklist checker. The concept behind the simple blacklist plugin is simple. Give it a list of terms or ip addresses to search for in a comment. If the comment contains any of these, discard it. Sad to say, it wasn't working, though. I looked through the code and could find nothing wrong, so submitted a bug report for it and let it go. The problem kept irking me, though, because every day I would have to manually moderate comments that contained text that I had in the blacklist, so I went back to debugging the plugin myself. I began by using var_dump(), the PHP function that will print any variable you give it. In particular, I used var_dump to see the contents of the blacklist. It was empty. Obviously, not good. You can't compare against something that doesn't exist. I looked at the code and found this: $blacklist= explode( "\n", Options::get('SimpleBlacklist:blacklist') ); I looked in the database options and found this: simpleblacklist:blacklist Note the capitalization differences. Changing the Options::get() statement to use 'simpleblacklist' solved the problem. The simpleblacklist plugin began quietly discarding comments that contained blacklisted terms. My life has become much easier without having to rely on an outside service. All thanks to the humble var_dump().

This entry is filed under , , and . You can follow any responses to this entry through the feed . New comments are currently closed.

5 Responses to The Humble var_dump

Hi Christian,

You know, I didn't even think about it. I'll remember it for next time, though.

On the other hand, everyone ( and shame on them for not doing so :) ) isn't using Habari - yet.

Commenting again on an relatively old post :)

I started using Defensio right after Bigjibby checked it in. It worked like a charm until recently. When the service is down, my whole commenting system is down. And mostly, it slows down the whole process.
I am seriously considering adapting the spamchecker+simpleblacklist combination. After all, I don't get much spam on my site anyway (ie. My site is not that popular :P)

As I mentioned in the post, I'm leery of outside services for spam defense, Ali. I've seen to many people have problems, including being prevented from commenting on their own blog. Even with WordPress, I've relied on Spam Karma II to do the work. My sites are none too busy, either. The combination of the simpleblacklist plugin and the spamchecker plugin have worked okay for me. I haven't had any false positives yet. As I add words and ip addresses to the blacklist the number of comments I have to moderate is going down. I'm pretty happy with the combination.

As far as committing the fix - it was done long ago, and the plugin was updated to work with the new formui system. Go for it!

What do you think?
Comments for this post are disabled.