Avoiding Duplicate Trackback Pings 1.0

October 16, 2003 - updated February 8, 2006

Sometimes an entry may receive multiple trackback pings from the same remote URL. These multiple pings don’t look good, take up unnecessary space in your database and increase your server load with unnecessary rebuilds.

This hack modifies MovableType to prevent duplicate trackback pings for an entry. If trackback ping from an existing remote URL contains the exact information as a previous ping, the MT database is not updated and no rebuild is necessary. If the remote ping contains modified information (for example the excerpt changed), the existing trackback is updated with the new information and your blog is rebuilt. In either case, a new trackback notification email is not sent.

Note for users of Jay Allen’s MT-Blacklist: Instead of modifying Trackback.pm, you should modify extlib/jayallen/MTBlPing.pm (in older versions of MT-Blacklist modify extlib/jayallen/Blacklist.pm).

lib/MT/App/Trackback.pm Modification

Go to your MovableType installation directory, and open the file Trackback.pm in the lib/MT/App subdirectory. Find the line that says:


and insert the following code before it:

    ## BEGIN HACK Avoid Duplicate Trackback Pings
    ## http://www.nonplus.net/software/mt/AvoidingDuplicateTrackbackPings.htm
    my $duplicate_ping = 0;
    if(my @existing_pings = MT::TBPing->load({
                blog_id => $ping->blog_id,
                tb_id => $ping->tb_id })) {
        foreach my $p (@existing_pings) {
            next unless ($p->source_url eq $ping->source_url);
            # If everything is the same, simply return
            return $app->_response if (($p->ip eq  $ping->ip)
                            && ($p->title eq $ping->title)
                            && ($p->blog_name eq $ping->blog_name)
                            && ($p->excerpt eq $ping->excerpt));
            # If something is different, copy new values to old ping
            # and replace new ping with old ping
            $ping = $p;
            $duplicate_ping = 1;
    ## END HACK Avoid Duplicate Trackback Pings

To disable the emailing of duplicate pings, find the line that says:

    if ($blog->email_new_pings) {

and replace is with the following line:

    if ($blog->email_new_pings && !$duplicate_ping) {  ## HACK Avoid Duplicate Trackback Pings