One ping’s enough, Jack

Could someone who actually understands Perl and Movable Type tell me if this makes sense? Back in the early days of Trackback crapflooding, when the flood was all supposedly coming from one source URL, I got to wondering what it would take to only accept one ping from one URL to one Trackback URL. It’s no longer any real use for that, but it’s still nice not to get multiple pings from everyone who has their PingTimeout set so low that they get tired of waiting for an answer long before you can tell them you got their ping.

Bunged into whatever file handles your pings ({MTdir}/extlib/jayallen/ or {MTdir}/lib/MT/App/ far enough into the ping subroutine that things are defined already (I favor putting it right above the commented out ## Check if user has pinged recently bit):

    ## already pinged?
    if ( MT::TBPing->count({ source_url => $url, tb_id => $tb_id }) ){
        $app->log("Double ping from $url to $tb_id");
        return $app->_response(Error =>
            $app->translate("Looks like you already pinged that. Thanks anyway."));		

Seems to me to work just fine to eliminate double pings. Can anyone see why it wouldn’t work, or some bad thing it would do that would explain why it isn’t already there? It will slow down the process of accepting a ping a tiny bit, of course, but that’s easily fixed by just increasing your PingTimeout setting in mt.cfg.

And speaking of PingTimeout, if you’re going to ping me, a nice long one would be a good idea. I haven’t decided yet whether or not to only accept pings from URLs that accept pings in return, but I am doing

    ## Plays well with others?
    use MT::Util qw( discover_tb );
    if ( discover_tb($url) ){
        $app->log("Found Tb data in $url");

after I get done making sure I haven’t already been pinged by that URL, so I need you to give me enough time to get your page, and look for your Trackback RDF, before I can tell you I’ve accepted the ping. So far (I’ve been doing it for a couple of weeks now), I’ve only had one ping that I know of that timed out waiting, and tried to ping again later (which was then caught by the “one ping’s enough, Jack, better not make it three” section, so it worked fine for me).


Comment by Jacques Distler #
2004-02-04 22:26:23

Here’s a slightly more sophisticated version of the same idea.

Seems to work well.

Comment by Phil Ringnalda #
2004-02-04 23:21:40

Interesting. Don’t know why I didn’t search first.

And wondering why Stepan’s loading on blog_id => $ping->blog_id, tb_id => $ping->tb_id and then going through every ping to that tb_id looking for a matching source_url reminded me that I added an index on source_url. Bad hacker, not writing it down at the time so I’d remember.

Probably is more polite to just return $app->_response silently, rather than rubbing people’s nose in their duplicate pings, isn’t it?

Comment by Phil Ringnalda #
2004-02-16 11:04:11

No sign of ”plays well with others” logged, so I could have denied you. Now where’s the duplicate ping?

Trackback by Neil's World #
2004-02-05 00:33:51

Avoiding duplicate trackbacks

Phil has unleashed a trackback hack that only allows you to ping an entry once with a particular URL. This has the advantage of stopping multiple trackback pings, and potentially alleviating crapflooders.

Trackback by Anonymous #
Name (required)
E-mail (required - never shown publicly)
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <del datetime="" cite=""> <dd> <dl> <dt> <em> <i> <ins datetime="" cite=""> <kbd> <li> <ol> <p> <pre> <q cite=""> <samp> <strong> <sub> <sup> <ul> in your comment.