I believe I solved the duplication problem.
For some reason the isDuplicate function doesn’t quite catch a duplicate.
I added a unique index to the hash column in the campaign_feeds table. I then tested for the insert and if it returns false, I don’t insert the post to wordpress’s posts table.
In processItem had to move:
$test = $wpdb->query(WPOTools::insertQuery($this->db[‘campaign_post’], array(
‘campaign_id’ => $campaign->id,
‘feed_id’ => $feed->id,
‘post_id’ => $postid,
‘hash’ => $this->getItemHash($item)
)));
if ($test == false)
return false;
to above this:
// Create post
$postid = $this->insertPost(
$wpdb->escape($item->get_title()),
$wpdb->escape($content),
$date, $categories, $campaign->posttype,
$this->feeduser, $campaign->allowpings,
$campaign->comment_status, $meta);
// If pingback/trackbacks
if ($campaign->dopingbacks) {
$this->log(‘Processing item pingbacks’);
require_once(ABSPATH . WPINC . ‘/comment.php’);
pingback($content, $postid);
}
also, I had to add the if $test statement to prevent lasthash from being overwritten:
// Processes post stack
foreach($items as $item) {
$test = $this->processItem($campaign, $feed, $item);
if ($test == true)
$lasthash = $this->getItemHash($item);
}
Also, in the activation section I had to change campaign_feed’s hash column definition from:
hash varchar(255) default ”,
to this:
hash varchar(255) default ” UNIQUE,
which adds a unique constraint to the insert statement.
I would add line numbers, but I’ve switched a bunch of other stuff around. It wouldn’t be accurate.
Note:
With the use of dbDelta, it won’t drop the table if it already exists, so deactivation and activation won’t work. Also, if you do drop the table the data already stored will be removed. However, since the only thing that needs to be changed is an add index, if you have access to your db at all, it is simple to make the modifications. Especially, with something like PHPMyAdmin.
All you do is find the table, click add index, name it hash or whatever, select unique from the dropdown menu and click save.
I’ll keep an eye on this thread to see if anyone has any problems or suggestions.
Done with WPMU 2.9.1