MT#56234 get_usr_preference_rs changes

* get_usr_preference now always returns a ResultSet object as it
  expected. If there is no preference found an empty ResultSet
  object is returned that does not have ->first. That is
  now in line with how the usage of the function works in the current
  codebase and should not produce errors when there was a preference
  requested that did not exist and 'undef' was returned instead of
  an object.
* remove 'skipping' debug code that caused a lot of spam in the
  panel-debug.log reporting skipped usr preferences for
  'subscriberadmin' and 'subscriber' roles

Change-Id: Ia9d033994e36afd48c2b6d91b08163f871a71b4c
mr11.2
Kirill Solomko 2 years ago
parent 8459e03f51
commit 81d50cdce1

@ -180,17 +180,14 @@ sub prepare_resource {
if ($c->user->roles eq 'subscriberadmin' || $c->user->roles eq 'subscriber') {
my $attrname = $pref->attribute->attribute;
if ($c->user->roles eq 'subscriberadmin' && ! $pref->attribute->expose_to_customer ) {
$c->log->debug("skipping attribute $attrname, not exposing to customer");
next;
}
if ($c->user->roles eq 'subscriber' && ! $pref->attribute->expose_to_subscriber ) {
$c->log->debug("skipping attribute $attrname, not exposing to subscriber");
next;
}
if ($has_profile && !$profile_allowed_attrs{$pref->attribute_id}) {
$c->log->debug("skipping attribute $attrname, not in profile");
next;
}
}
@ -2446,10 +2443,13 @@ sub get_usr_preference_rs {
? (expose_to_customer => 1) : (),
$c->user->roles eq 'subscriber'
? (expose_to_subscriber => 1) : (),
})->first;
return unless($pref_rs);
});
unless ($pref_rs && $pref_rs->first) {
# an ResultSet object is expected as the return value
return $pref_rs;
}
my $attribute_id = $pref_rs->id;
my $attribute_id = $pref_rs->first->id;
# filter by allowed attrs from profile
if (($c->user->roles eq 'subscriberadmin' || $c->user->roles eq 'subscriber') &&
@ -2457,19 +2457,16 @@ sub get_usr_preference_rs {
my $found_attr = $prov_subscriber->voip_subscriber_profile
->profile_attributes->search_rs({
attribute_id => $attribute_id,
})->first;
unless ($found_attr) {
$c->log->debug("get_usr_preference_rs skipping attr '$attribute' not in profile");
return;
}
});
return $found_attr unless $found_attr->first;
}
$pref_rs = $pref_rs->voip_usr_preferences;
$pref_rs = $pref_rs->first->voip_usr_preferences;
if ($prov_subscriber) {
$pref_rs = $pref_rs->search({
subscriber_id => $prov_subscriber->id,
attribute_id => $attribute_id
});
subscriber_id => $prov_subscriber->id,
attribute_id => $attribute_id
});
}
return $pref_rs;

Loading…
Cancel
Save