Bug 17835: Do not reselect translated_description if comes from search_with_localization

If the Koha::ItemType object has been instanciated from a call to
Koha::ItemTypes->search_with_localization, we already have the
translated_description value. So there is no need to fetch it again from
the DB. This is what this trick does: if the translated_description
column exist in the DBIx::Class result source's column list, that means
the value has already been retrieved.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2017-01-03 09:22:48 +01:00 committed by Kyle M Hall
parent 80018625cf
commit 53ce807f6e
1 changed files with 8 additions and 0 deletions

View File

@ -51,6 +51,14 @@ sub image_location {
sub translated_description {
my ( $self, $lang ) = @_;
if ( my $translated_description = eval { $self->get_column('translated_description') } ) {
# If the value has already been fetched (eg. from sarch_with_localization),
# do not search for it again
# Note: This is a bit hacky but should be fast
return $translated_description
? $translated_description
: $self->description;
}
$lang ||= C4::Languages::getlanguage;
my $translated_description = Koha::Localizations->search({
code => $self->itemtype,