Bug 20443: Do not explode if attribute does not have a valid av

Template process failed: undef error -
Can't call method "lib" on an undefined value at /kohadevbox/koha/Koha/Patron/Attribute.pm line 109.
                                                    at /kohadevbox/koha/C4/Templates.pm line 122

We should not crash as it if the attribute is linked to an invalid
authorised value (for instance the AV has been deleted)

We must provide a check in the search_for_data_inconsistencies.pl script

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-03-09 11:02:54 +01:00 committed by Martin Renvoize
parent fc430529c1
commit 994ea386c3
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -106,7 +106,8 @@ displayed instead of the code.
sub description {
my ( $self) = @_;
if ( $self->type->authorised_value_category ) {
return $self->authorised_value->lib;
my $av = $self->authorised_value;
return $av ? $av->lib : "";
}
return $self->attribute;
}