Improve the performance of getThumbnailUrl by 1400%. Fixes bug #11346

This commit is contained in:
Colin Kuskie 2010-01-19 15:57:28 -08:00
parent ea53dcc037
commit 066e654640
3 changed files with 8 additions and 6 deletions

View file

@ -13,6 +13,7 @@
- fixed #11347: copy forum - fixed #11347: copy forum
- fixed #11359: USPS International shipping does not work on United Kingdom - fixed #11359: USPS International shipping does not work on United Kingdom
- fixed #11034: Upgrade errors -- 7.6.35 to 7.7.17 - fixed #11034: Upgrade errors -- 7.6.35 to 7.7.17
- fixed #11346: Slow rendering of Thread asset with a lot of attachments
7.8.9 7.8.9
- fixed #11235: wiki search - fixed #11235: wiki search

View file

@ -1247,14 +1247,15 @@ sub getThumbnailUrl {
my $self = shift; my $self = shift;
my $filename = shift; my $filename = shift;
if (! defined $filename) { if (! defined $filename) {
$self->session->errorHandler->error("Can't make a thumbnail url without a filename."); $self->session->errorHandler->error("Can't find a thumbnail url without a filename.");
return ''; return '';
} }
if (! isIn($filename, @{ $self->getFiles() })) { my $thumbname = 'thumb-' . $filename;
$self->session->errorHandler->error("Can't make a thumbnail for a file named '$filename' that is not in my storage location."); if (! -e $self->getPath($thumbname)) {
$self->session->errorHandler->error("Can't find a thumbnail for a file named '$filename' that is not in my storage location.");
return ''; return '';
} }
return $self->getUrl("thumb-".$filename); return $self->getUrl($thumbname);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -203,10 +203,10 @@ is($imageCopy->deleteFile('../../'), undef, 'deleteFile in Storage::Image also r
#################################################### ####################################################
is($thumbStore->getThumbnailUrl(), '', 'getThumbnailUrl returns undef if no file is sent'); is($thumbStore->getThumbnailUrl(), '', 'getThumbnailUrl returns undef if no file is sent');
is($WebGUI::Test::logger_error, q/Can't make a thumbnail url without a filename./, 'getThumbnailUrl logs an error message for not sending a filename'); is($WebGUI::Test::logger_error, q/Can't find a thumbnail url without a filename./, 'getThumbnailUrl logs an error message for not sending a filename');
is($thumbStore->getThumbnailUrl('round.png'), '', 'getThumbnailUrl returns undef if the requested file is not in the storage location'); is($thumbStore->getThumbnailUrl('round.png'), '', 'getThumbnailUrl returns undef if the requested file is not in the storage location');
is($WebGUI::Test::logger_error, q/Can't make a thumbnail for a file named 'round.png' that is not in my storage location./, 'getThumbnailUrl logs an error message for not sending a filename'); is($WebGUI::Test::logger_error, q/Can't find a thumbnail for a file named 'round.png' that is not in my storage location./, 'getThumbnailUrl logs an error message for not sending a filename');
is($thumbStore->getThumbnailUrl('square.png'), $thumbStore->getUrl('thumb-square.png'), 'getThumbnailUrl returns the correct url'); is($thumbStore->getThumbnailUrl('square.png'), $thumbStore->getUrl('thumb-square.png'), 'getThumbnailUrl returns the correct url');