Fixed the search function that broke in 7.0.7.

also fixed a user profile problemm
This commit is contained in:
JT Smith 2006-09-26 20:34:59 +00:00
parent 41bd19736c
commit 58b3128a3a
6 changed files with 51 additions and 37 deletions

View file

@ -27,6 +27,10 @@
- fix: File Upload - documented HTTP file upload size limitations in File
Pile Assets Hover help as well as the WebGUI settings documentation for Max
Upload size.
- Eliminated several hundred queries to the database during certain user
profile field options.
- Fixed the search function that broke in 7.0.7.
7.0.7
- rfe: Image Management (funded by Formation Design Systems)

View file

@ -7,6 +7,14 @@ upgrading from one version to the next, or even between multiple
versions. Be sure to heed the warnings contained herein as they will
save you many hours of grief.
7.0.8
--------------------------------------------------------------------
* 7.0.7 was released with a critical bug that broke the search engine
for many sites, but not all. This bug has been corrected and tests
have been written to help ensure it doesn't happen again. However,
as a result you must rerun the search indexer program (sbin/search.pl)
on all your sites.
7.0.4
--------------------------------------------------------------------

View file

@ -20,19 +20,21 @@ my $quiet; # this line required
my $session = start(); # this line required
fixRobotsTxtMimeType($session);
fixSearch();
# upgrade functions go here
finish($session); # this line required
##-------------------------------------------------
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about.\n" unless ($quiet);
# # and here's our code
#}
#-------------------------------------------------
sub fixSearch {
print "\tFixing search.\n" unless ($quiet);
$session->db->write("alter table assetIndex add column lineage varchar(255)");
}
#-------------------------------------------------
sub fixRobotsTxtMimeType {
my $session = shift;
print "\tFixing MIME type of robots.txt snippet.\n" unless $quiet;

View file

@ -37,17 +37,23 @@ These methods are available from this package:
#-------------------------------------------------------------------
sub _getQuery {
=head2 _getQuery ( columnsToSelect )
This is a private method and should never be used outside of this class.
=cut
sub _getQuery {
my $self = shift;
my $selectsRef = shift;
return
('select ' . join(', ', @$selectsRef,
($self->{_score}? $self->{_score} : ())) .
' from assetIndex inner join asset on assetIndex.assetId = asset.assetId where ' .
($self->{_isPublic}? 'isPublic = 1 and ' : '') . '('.$self->{_where}.')' .
($self->{_score}? ' order by score desc' : ''));
return ('select ' . join(', ', @$selectsRef, ($self->{_score} ? $self->{_score} : ())) . ' from assetIndex where '
. ($self->{_isPublic}? 'isPublic = 1 and ' : '')
. '('.$self->{_where}.')'
. ($self->{_score} ? ' order by score desc' : '')
);
}
#-------------------------------------------------------------------
=head2 getAssetIds ( )
@ -58,7 +64,7 @@ Returns an array reference containing all the asset ids of the assets that match
sub getAssetIds {
my $self = shift;
my $query = $self->_getQuery(['assetIndex.assetId']);
my $query = $self->_getQuery(['assetId']);
my $rs = $self->session->db->prepare($query);
$rs->execute($self->{_params});
my @ids = ();
@ -79,8 +85,7 @@ Returns an array reference containing asset objects for those that matched.
sub getAssets {
my $self = shift;
my $query = $self->_getQuery(['assetIndex.assetId', 'assetIndex.className',
'assetIndex.revisionDate']);
my $query = $self->_getQuery([qw(assetId className revisionDate)]);
my $rs = $self->session->db->prepare($query);
$rs->execute($self->{_params});
my @assets = ();
@ -126,11 +131,7 @@ sub getPaginatorResultSet {
my $paginate = shift;
my $pageNumber = shift;
my $formVar = shift;
my $query = $self->_getQuery(['assetIndex.assetId', 'assetIndex.title',
'assetIndex.url', 'assetIndex.synopsis',
'assetIndex.ownerUserId', 'assetIndex.groupIdView',
'assetIndex.groupIdEdit', 'assetIndex.creationDate',
'assetIndex.revisionDate', 'assetIndex.className']);
my $query = $self->_getQuery([qw(assetId title url synopsis ownerUserId groupIdView groupIdEdit creationDate revisionDate className)]);
my $paginator = WebGUI::Paginator->new($self->session, $url, $paginate, $pageNumber, $formVar);
$paginator->setDataByQuery($query, undef, undef, $self->{_params});
return $paginator;
@ -146,18 +147,14 @@ Returns a WebGUI::SQL::ResultSet object containing the search results with colum
sub getResultSet {
my $self = shift;
my $query = $self->_getQuery(['assetIndex.assetId', 'assetIndex.title',
'assetIndex.url', 'assetIndex.synopsis',
'assetIndex.assetId', 'assetIndex.title',
'assetIndex.url', 'assetIndex.synopsis',
'assetIndex.ownerUserId', 'assetIndex.groupIdView',
'assetIndex.groupIdEdit', 'assetIndex.creationDate',
'assetIndex.revisionDate', ' assetIndex.className']);
my $query = $self->_getQuery([qw(assetId title url synopsis ownerUserId groupIdView groupIdEdit creationDate revisionDate className)]);
my $rs = $self->session->db->prepare($query);
$rs->execute($self->{_params});
return $rs;
}
#-------------------------------------------------------------------
=head2 new ( session [ , isPublic ] )
@ -291,15 +288,15 @@ sub search {
$keywords = join(" ", @terms);
}
push(@params, $keywords, $keywords);
$self->{_score} = "match (assetIndex.keywords) against (?) as score";
push(@clauses, "match (assetIndex.keywords) against (? in boolean mode)");
$self->{_score} = "match (keywords) against (?) as score";
push(@clauses, "match (keywords) against (? in boolean mode)");
}
if ($rules->{lineage}) {
my @phrases = ();
foreach my $lineage (@{$rules->{lineage}}) {
next unless defined $lineage;
push(@params, $lineage."%");
push(@phrases, "asset.lineage like ?");
push(@phrases, "lineage like ?");
}
push(@clauses, join(" or ", @phrases)) if (scalar(@phrases));
}
@ -308,20 +305,20 @@ sub search {
foreach my $class (@{$rules->{classes}}) {
next unless defined $class;
push(@params, $class);
push(@phrases, "assetIndex.className=?");
push(@phrases, "className=?");
}
push(@clauses, join(" or ", @phrases)) if (scalar(@phrases));
}
if ($rules->{creationDate}) {
my $start = $rules->{creationDate}{start} || 0;
my $end = $rules->{creationDate}{end} || 9999999999999999999999;
push(@clauses, "assetIndex.creationDate between ? and ?");
push(@clauses, "creationDate between ? and ?");
push(@params, $start, $end);
}
if ($rules->{revisionDate}) {
my $start = $rules->{revisionDate}{start} || 0;
my $end = $rules->{revisionDate}{end} || 9999999999999999999999;
push(@clauses, "assetIndex.revisionDate between ? and ?");
push(@clauses, "revisionDate between ? and ?");
push(@params, $start, $end);
}
$self->{_params} = \@params;

View file

@ -131,10 +131,10 @@ sub create {
#-------------------- added by zxp end
my $add = $self->session->db->prepare("insert into assetIndex (assetId, title, url, creationDate, revisionDate,
ownerUserId, groupIdView, groupIdEdit, className, synopsis, keywords) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
ownerUserId, groupIdView, groupIdEdit, lineage, className, synopsis, keywords) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
$add->execute([$asset->getId, $asset->get("title"), $asset->get("url"), $asset->get("creationDate"),
$asset->get("revisionDate"), $asset->get("ownerUserId"), $asset->get("groupIdView"), $asset->get("groupIdEdit"),
$asset->get("className"), $synopsis, $keywords]);
$asset->get("lineage"), $asset->get("className"), $synopsis, $keywords]);
return $self;
}

View file

@ -439,7 +439,10 @@ sub profileField {
$self = shift;
$fieldName = shift;
$value = shift;
die "No such profile field: $fieldName" unless $self->session->db->quickArray("SELECT COUNT(*) FROM userProfileField WHERE fieldName = ?", [$fieldName]);
if (!exists $self->{_profile}{$fieldName} && !$self->session->db->quickArray("SELECT COUNT(*) FROM userProfileField WHERE fieldName = ?", [$fieldName])) {
$self->session->warn("No such profile field: $fieldName");
return undef;
}
if (defined $value) {
$self->uncache;
$self->{_profile}{$fieldName} = $value;