Skip to content

Commit

Permalink
Item2276: remove premature creation of webobject
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@6893 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Mar 25, 2010
1 parent 48b6254 commit 1d26349
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 49 deletions.
3 changes: 1 addition & 2 deletions core/lib/Foswiki/Macros/FOREACH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ sub FOREACH {
# $params->{footer} = '' unless ( $params->{footer} );
my $s;
try {
my $webObject = Foswiki::Meta->new( $this, $params->{baseweb} );
my $topicString = $params->{_DEFAULT} || '';
#from Search::_makeTopicPattern (plus an added . to allow web.topic)
my @topics = map { s/[^\*\_\-\+\.$Foswiki::regex{mixedAlphaNum}]//go; s/\*/\.\*/go; $_ }
Expand All @@ -29,7 +28,7 @@ sub FOREACH {
my $query; #query node
require Foswiki::Search::InfoCache;
my $infoCache = new Foswiki::Search::InfoCache($this, $params->{baseweb}, \@topics);
my ( $ttopics, $searchResult, $tmplTail ) = $this->search->formatResults($webObject, $query, $infoCache, $params);
my ( $ttopics, $searchResult, $tmplTail ) = $this->search->formatResults($query, $infoCache, $params);
$s = $searchResult;
}
catch Error::Simple with {
Expand Down
67 changes: 20 additions & 47 deletions core/lib/Foswiki/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,6 @@ sub searchWeb {

$params{type} = 'regex' if ( $params{regex} );

my $mixedAlpha = $Foswiki::regex{mixedAlpha};
my $separator = $params{separator};
if ( defined($separator) ) {
$separator =~ s/\$n\(\)/\n/gos; # expand "$n()" to new line
$separator =~ s/\$n([^$mixedAlpha]|$)/\n$1/gos;
}
$params{separator} = $separator;
my $newLine = $params{newline} || '';
if ($newLine) {
$newLine =~ s/\$n\(\)/\n/gos; # expand "$n()" to new line
$newLine =~ s/\$n([^$mixedAlpha]|$)/\n$1/gos;
}

# A value of 'all' or 'on' by itself gets all webs,
# otherwise ignored (unless there is a web called 'All'.)
my $searchAllFlag = ( $webNames =~ /(^|[\,\s])(all|on)([\,\s]|$)/i );
my @webs = Foswiki::Search::InfoCache::_getListOfWebs( $webNames, $recurse, $searchAllFlag );

###################the search
my $query = $this->parseSearch($searchString, \%params );
#setting the inputTopicSet to be undef allows the search/query algo to use
Expand Down Expand Up @@ -334,37 +316,30 @@ sub searchWeb {
&$callback( $cbdata, $tmplSearch );
}

# Loop through webs
my $ttopics = 0;
my $prefs = $session->{prefs};
# foreach my $web (@webs) {
# if ( $params{noempty} && !$infoCache->hasNext() ) {
# next; # Nothing to show for this web
# }

# add legacy SEARCH separator - see Item1773 (TODO: find a better approach)
# &$callback( $cbdata, $separator )
# if ( ( $ttopics > 0 ) and $noFooter and $noSummary and $separator );

my $webObject;# = Foswiki::Meta->new( $session, $web );

#TODO: quick hackjob - see what the feature proposal gives before it becomes public
$params{partition_output} = 'web';

#TODO: quick hackjob - see what the feature proposal gives before it becomes public
$params{partition_output} = 'web';

my ( $web_ttopics, $web_searchResult );
( $web_ttopics, $web_searchResult ) =
$this->formatResults( $webObject, $query, $infoCache, \%params );
my ( $numberOfResults, $web_searchResult ) =
$this->formatResults( $query, $infoCache, \%params );

$ttopics += $web_ttopics;
return if ( defined $params{_callback} );

# #paging
# if ( defined($showpage) and $params{pager_show_results_to} > 0 ) {
# $params{pager_show_results_to} -= $web_ttopics;
# last if ( $params{pager_show_results_to} <= 0 );
# }
# } # end of: foreach my $web ( @webs )

return if ( defined $params{_callback} );
#TODO: this code ($separator and $newLine) used to be a long way higher, and the processing might still be needed?
my $mixedAlpha = $Foswiki::regex{mixedAlpha};
my $separator = $params{separator};
if ( defined($separator) ) {
$separator =~ s/\$n\(\)/\n/gos; # expand "$n()" to new line
$separator =~ s/\$n([^$mixedAlpha]|$)/\n$1/gos;
}
$params{separator} = $separator;
my $newLine = $params{newline} || '';
if ($newLine) {
$newLine =~ s/\$n\(\)/\n/gos; # expand "$n()" to new line
$newLine =~ s/\$n([^$mixedAlpha]|$)/\n$1/gos;
}

my $searchResult = join( '', @{ $params{_cbdata} } );
if ( $formatDefined && !$finalTerm ) {
Expand Down Expand Up @@ -486,11 +461,9 @@ the hash of subs can take care of %MACRO{}% specific complex to evaluate replace
=cut

sub formatResults {
my ( $this, $webObject__GONE, $query, $infoCache, $params ) = @_;
my ( $this, $query, $infoCache, $params ) = @_;
my $session = $this->{session};
my $users = $session->{users};
# my $web = $webObject->web;
# my $thisWebNoSearchAll = $webObject->getPreference('NOSEARCHALL') || '';

my ( $callback, $cbdata ) = setup_callback($params);

Expand Down

0 comments on commit 1d26349

Please sign in to comment.