Revert "Revert "don't insert the same notice twice into an inbox""

This reverts commit a09b27ff41.
This commit is contained in:
Evan Prodromou 2010-04-01 12:57:52 -04:00
parent a09b27ff41
commit 9efe5393ff
1 changed files with 10 additions and 0 deletions

View File

@ -114,6 +114,16 @@ class Inbox extends Memcached_DataObject
return false;
}
$ids = unpack('N*', $inbox->notice_ids);
// bulk inserts sometimes fail and get restarted.
// Skip if this one has been inserted before.
if (in_array($notice_id, $ids)) {
// effectively successful
return true;
}
$result = $inbox->query(sprintf('UPDATE inbox '.
'set notice_ids = concat(cast(0x%08x as binary(4)), '.
'substr(notice_ids, 1, %d)) '.