diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 8aaf8dcf7..11ed462a1 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -22,6 +22,7 @@ - fixed #11960: Billing address mandatory fields not specified - fixed #11975: Cannot paste threads: "Cannot call method isa()" - fixed #11976: Use Container URL in search gives user Permission Denied + - fixed #11985: Search.pl should warn on bad assets 7.10.6 - fixed #11974: Toolbar icons unclickable in Webkit using HTML5 diff --git a/sbin/search.pl b/sbin/search.pl index d086e0fa3..b5249d59a 100755 --- a/sbin/search.pl +++ b/sbin/search.pl @@ -19,6 +19,13 @@ BEGIN { $webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir)); unshift @INC, File::Spec->catdir($webguiRoot, 'lib'); } +foreach my $libDir ( readLines( "preload.custom" ) ) { + if ( !-d $libDir ) { + warn "WARNING: Not adding lib directory '$libDir' from preload.custom: Directory does not exist.\n"; + next; + } + unshift @INC, $libDir; +} use Getopt::Long; use WebGUI::Asset; @@ -89,7 +96,11 @@ sub reindexSite { my @searchableAssetIds; while (my ($id, $class) = $rs->array) { my $asset = WebGUI::Asset->new($session,$id,$class); - if (defined $asset && $asset->get("state") eq "published" && ($asset->get("status") eq "approved" || $asset->get("status") eq "archived")) { + if ( !$asset ) { + warn sprintf "- Asset %s (%s) could not be instantiated\n", $id, $class; + next; + } + if ($asset->get("state") eq "published" && ($asset->get("status") eq "approved" || $asset->get("status") eq "archived")) { print $asset->getId."\t".$asset->getTitle."\t"; my $t = [Time::HiRes::gettimeofday()]; $asset->indexContent; @@ -143,6 +154,23 @@ sub updateSite { print "\nSite indexing took ".Time::HiRes::tv_interval($siteTime)." seconds.\n"; } +#------------------------------------------------- +sub readLines { + my $file = shift; + my @lines; + if (open(my $fh, '<', $file)) { + while (my $line = <$fh>) { + $line =~ s/#.*//; + $line =~ s/^\s+//; + $line =~ s/\s+$//; + next if !$line; + push @lines, $line; + } + close $fh; + } + return @lines; +} + __END__ =head1 NAME