Bug 10872 - C4::Items GetHiddenItems fix and optimization

There should be a:
"require YAML;"
or
"use YAML qw/Load/;"

as the GetHiddenItems routine has a reference to YAML::Load.

This was discovered while adding a GetHiddenItems() call into
opac/opac-MARCdetail.pl. I believe this problem dates back to
bug 6488 or bug 5984.

I also added an optimization to GetHiddenItems to prevent
processing if there is nothing in the system preference. Test
by searching for a biblio which has some or all of its items
hidden.

Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Maybe
  return () unless $yaml =~ /\S/;
or
  return () if $yaml =~ /^\s*$/;
would have been easier to read.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Mark Tompsett 2013-09-10 16:19:58 -04:00 committed by Galen Charlton
parent e191bb02bf
commit 9ab593440b

View file

@ -30,6 +30,7 @@ use MARC::Record;
use C4::ClassSource;
use C4::Log;
use List::MoreUtils qw/any/;
use YAML qw/Load/;
use Data::Dumper; # used as part of logging item record changes, not just for
# debugging; so please don't remove this
@ -1629,6 +1630,7 @@ sub GetHiddenItemnumbers {
my @resultitems;
my $yaml = C4::Context->preference('OpacHiddenItems');
return () if (! $yaml =~ /\S/ );
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
my $hidingrules;
eval {