summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2008-02-20 02:07:03 +0000
committerivan <ivan>2008-02-20 02:07:03 +0000
commitc08ff0f1990dc75050ce062ede736e534bc8ef18 (patch)
tree6d528bcd7512e82ffdd89928adc4de1f69069fc2 /FS
parent9f2de9917c8ff7fecd1d17ac7567472b5ac75df0 (diff)
retry collisions a bit, acme is getting duplicate errors... guess they're using lots and lots of prepaid cards. closes: RT#3104
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/prepay_credit.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/FS/FS/prepay_credit.pm b/FS/FS/prepay_credit.pm
index bf85dfaa6..302ba37c7 100644
--- a/FS/FS/prepay_credit.pm
+++ b/FS/FS/prepay_credit.pm
@@ -162,10 +162,18 @@ sub generate {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
+ my $condup = 0; #don't retry forever
+
my @cards = ();
for ( 1 ... $num ) {
+
+ my $identifier = join('', map($codeset[int(rand $#codeset)], (0..7) ) );
+
+ redo if qsearchs('prepay_credit',{identifier=>$identifier}) && $condup++<23;
+ $condup = 0;
+
my $prepay_credit = new FS::prepay_credit {
- 'identifier' => join('', map($codeset[int(rand $#codeset)], (0..7) ) ),
+ 'identifier' => $identifier,
%$hashref,
};
my $error = $prepay_credit->check || $prepay_credit->insert;