From 9cfcf84c2fb442b2651fdbacbf2b5cf14b37cf5c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 25 May 2010 12:02:32 -0700 Subject: [PATCH] Handle the edge case where no fields are to be returned in a Thingy search. Fixes bug #11587 --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/Thingy.pm | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 9973d8bd6..7a4d5df74 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -8,6 +8,7 @@ - fixed #11584: Errors on checkout when payment problems occur - fixed #11582: Registering with a .mobi email address - fixed #11580: Date not populated for Story Archive RSS feed + - fixed #11587: Thingy, no fields and undefined statement handles 7.9.5 - Asset->www_copy now has a progress bar diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 3716f52e2..fb13b64ae 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -3357,18 +3357,20 @@ sequenceNumber'); WebGUI::Cache->new($self->session,"query_".$thingId)->set($query,30*60); $paginatePage = $self->session->form->param('pn') || 1; - $currentUrl = $self->session->url->append($currentUrl, "orderBy=".$orderBy) if $orderBy; - + $currentUrl = $self->session->url->append($currentUrl, "orderBy=".$orderBy) if $orderBy; + $p = WebGUI::Paginator->new($self->session,$currentUrl,$thingProperties->{thingsPerPage}, undef, $paginatePage); - my $sth = $self->session->db->read($query) if ! $noFields; my @visibleResults; - while (my $result = $sth->hashRef){ - if ($self->canViewThingData($thingId,$result->{thingDataId})){ - push(@visibleResults,$result); + if (! $noFields) { + my $sth = $self->session->db->read($query) if ! $noFields; + while (my $result = $sth->hashRef){ + if ($self->canViewThingData($thingId,$result->{thingDataId})){ + push(@visibleResults,$result); + } } } - $p->setDataByArrayRef(\@visibleResults) if ! $noFields; + $p->setDataByArrayRef(\@visibleResults); $searchResults = $p->getPageData($paginatePage); foreach my $searchResult (@$searchResults){