Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F125287963
D5895.1779404206.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D5895.1779404206.diff
View Options
diff --git a/src/app/Policy/Greylist.php b/src/app/Policy/Greylist.php
--- a/src/app/Policy/Greylist.php
+++ b/src/app/Policy/Greylist.php
@@ -7,6 +7,7 @@
use App\Policy\Utils as PolicyUtils;
use App\Utils;
use Carbon\Carbon;
+use Illuminate\Database\UniqueConstraintViolationException;
use Illuminate\Support\Facades\DB;
class Greylist
@@ -215,17 +216,27 @@
$connect->save();
} else {
- $connect = Connect::create([
- 'sender_local' => $this->senderLocal,
- 'sender_domain' => $this->senderDomain,
- 'net_id' => $this->netID,
- 'net_type' => $this->netType,
- 'recipient_hash' => $this->recipientHash,
- 'recipient_id' => $this->recipientID,
- 'recipient_type' => $this->recipientType,
- 'created_at' => $this->timestamp,
- 'updated_at' => $this->timestamp,
- ]);
+ try {
+ $connect = Connect::create([
+ 'sender_local' => $this->senderLocal,
+ 'sender_domain' => $this->senderDomain,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType,
+ 'recipient_hash' => $this->recipientHash,
+ 'recipient_id' => $this->recipientID,
+ 'recipient_type' => $this->recipientType,
+ 'created_at' => $this->timestamp,
+ 'updated_at' => $this->timestamp,
+ ]);
+ } catch (UniqueConstraintViolationException $e) {
+ // It occasionally happens that in meantime another process created the same record.
+ // In this case, we just ignore the error and select that record.
+ if ($connect = $this->findConnectsCollection()->first()) {
+ // FIXME: We do not seem to be using connect_count anywhere, should we bother with an update?
+ $connect->connect_count++;
+ $connect->save();
+ }
+ }
}
$this->connect = $connect;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, May 21, 10:56 PM (4 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18929588
Default Alt Text
D5895.1779404206.diff (2 KB)
Attached To
Mode
D5895: Nicely handle "duplicate entry" errors in greylisting
Attached
Detach File
Event Timeline