MT#60520 prov templates: fix lookup of items

item (contract, contact, subscriber) lookup will pick the first
matching element (an arbitrary one if multiple are matching).

ie. when lookup identifiers are too loose (f.ex. subscribers
without domain in a multidomain setup) it might pick a wrong
item - which is ok (supposed to bail out at a later step)
unless that wrong item is a *terminated* one, causing to
proceed checks on a terminated record (which can never
happen from API or UI side since those hide terminated items),
which produces a misleading 500 error in the end.

we prevent this now by ensuring that looked up items are
not terminated ones. even if the looked up items is not
the desired one, becasue of an inaccurate template.

Change-Id: I6691937c2e62b05915c7eac9980224abe2185b2c
(cherry picked from commit 0fd36ace55)
(cherry picked from commit 0f49754134)
mr12.4.1
Rene Krenn 10 months ago committed by Marco Capetta
parent 9373fa034e
commit 1fbccb8e17

@ -785,13 +785,14 @@ sub _init_contract_context {
}
$context->{contract_contact} = \%contract_contact;
if (scalar @identifiers) {
my $e = $schema->resultset('contacts')->search_rs({
map { $_ => $contract_contact{$_}; } @identifiers
})->first;
if ($e and 'terminated' ne $e->status) {
$contract_contact{id} = $e->id;
} else {
delete $contract_contact{id};
delete $contract_contact{id};
foreach my $e ($schema->resultset('contacts')->search_rs({
map { $_ => $contract_contact{$_}; } @identifiers
})->all) {
if ('terminated' ne $e->status) {
$contract_contact{id} = $e->id;
last;
}
}
} else {
delete $contract_contact{id};
@ -863,13 +864,14 @@ sub _init_contract_context {
$context->{contract} = \%contract;
if (scalar @identifiers) {
my $e = $schema->resultset('contracts')->search_rs({
map { $_ => $contract{$_}; } @identifiers
})->first;
if ($e and 'terminated' ne $e->status) {
$contract{id} = $e->id;
} else {
delete $contract{id};
delete $contract{id};
foreach my $e ($schema->resultset('contracts')->search_rs({
map { $_ => $contract{$_}; } @identifiers
})->all) {
if ('terminated' ne $e->status) {
$contract{id} = $e->id;
last;
}
}
} else {
delete $contract{id};
@ -930,15 +932,17 @@ sub _init_subscriber_context {
my $item;
if (scalar @identifiers) {
$item = $schema->resultset('voip_subscribers')->search_rs({
map { $_ => $subscriber{$_}; } @identifiers
},{
join => 'domain',
})->first;
if ($item and 'terminated' ne $item->status) {
$subscriber{id} = $item->id;
} else {
delete $subscriber{id};
delete $subscriber{id};
foreach my $e ($schema->resultset('voip_subscribers')->search_rs({
map { $_ => $subscriber{$_}; } @identifiers
},{
#join => 'domain',
})->all) {
if ('terminated' ne $e->status) {
$subscriber{id} = $e->id;
$item = $e;
last;
}
}
} else {
delete $subscriber{id};

Loading…
Cancel
Save