From d72dd218265673732bdb4771788be91c436191a6 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 7 Jul 2005 19:53:19 +0000 Subject: [PATCH] fixed a couple bugs and added size aware file cache --- docs/changelog/6.x.x.txt | 2 ++ docs/gotcha.txt | 6 +++++ docs/upgrades/upgrade_6.2.11-6.3.0.pl | 4 +++- docs/upgrades/upgrade_6.6.3-6.7.0.pl | 17 +++++++++++++ etc/WebGUI.conf.original | 4 ++++ lib/WebGUI/Asset/Wobject/Article.pm | 17 ++++++------- .../Asset/Wobject/IndexedSearch/Search.pm | 2 +- lib/WebGUI/Cache/FileCache.pm | 23 ++++++++++++++++-- sbin/Hourly/CleanFileCache.pm | 24 +++++++++++++++++++ 9 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 sbin/Hourly/CleanFileCache.pm diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index e33f2a740..1691f8ad1 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,4 +1,5 @@ 6.7.0 + - Added asset versioning. - fix [ 1229188 ] typo in Help: Collaboration, Post List Template Variables - fix [ 1221284 ] Operation\user.pm i18n {internationalize labels} - All form field labels have been internationalized. @@ -14,6 +15,7 @@ way to upload files will be through the File Pile. Anyone wishing to make the File and Image assets available as normal assets in the new content menu are still able to do so, and existing sites will be left as they are. + - Added a file cache size limit option to the config file. 6.6.3 diff --git a/docs/gotcha.txt b/docs/gotcha.txt index b6558bcd5..91bd3592b 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -7,6 +7,12 @@ 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. +6.7.0 +-------------------------------------------------------------------- + * The asset API has changed slightly due to versioning, so if you + have any custom assets, check out migration.txt to make + sure they will comply. + 6.6.3 -------------------------------------------------------------------- diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.pl b/docs/upgrades/upgrade_6.2.11-6.3.0.pl index f9fab4ebd..b5ff37a16 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.pl @@ -432,6 +432,8 @@ $sth->finish; print "\tConverting collateral manager items into assets\n" unless ($quiet); +WebGUI::SQL->write("update collateral set collateralFolderId='0' where collateralFolderId=''"); +WebGUI::SQL->write("update collateral set collateralFolderId='0' where collateralFolderId is null"); my $collateralRootLineage = getNextLineage('PBasset000000000000002'); my $collateralRootId = WebGUI::SQL->setRow("asset","assetId",{ assetId=>"new", @@ -500,7 +502,7 @@ my $lastCollateralFolderId = 'nolastid'; my ($parentId, $baseLineage); my $sth = WebGUI::SQL->read("select * from collateral order by collateralFolderId"); while (my $data = $sth->hashRef) { - next if ($data->{filename} eq ""); + next if ($data->{filename} eq "" && $data->{collateralType} ne "snippet"); print "\t\tConverting collateral item ".$data->{collateralId}." for folder ".$data->{collateralFolderId}."\n" unless ($quiet); unless ($lastCollateralFolderId eq $data->{collateralFolderId}) { my $id = $data->{collateralFolderId}; diff --git a/docs/upgrades/upgrade_6.6.3-6.7.0.pl b/docs/upgrades/upgrade_6.6.3-6.7.0.pl index ec6b8e3aa..f87ad9606 100644 --- a/docs/upgrades/upgrade_6.6.3-6.7.0.pl +++ b/docs/upgrades/upgrade_6.6.3-6.7.0.pl @@ -21,12 +21,29 @@ GetOptions( WebGUI::Session::open("../..",$configFile); addAssetVersioning(); +updateConfigFile(); insertHelpTemplate(); insertXSLTSheets(); insertSyndicatedContentTemplate(); WebGUI::Session::close(); +sub updateConfigFile { + print "\tUpdating config file.\n" unless ($quiet); + my $pathToConfig = '../../etc/'.$configFile; + my $conf = Parse::PlainConfig->new('DELIM' => '=', 'FILE' => $pathToConfig, 'PURGE'=>1); + my %newConfig; + foreach my $key ($conf->directives) { # delete unwanted stuff + unless ($key eq "wobject") { + $newConfig{$key} = $conf->get($key); + } + } + $newConfig{fileCacheSizeLimit} = 100000000; + $conf->purge; + $conf->set(%newConfig); + $conf->write; +} + sub addAssetVersioning { print "\tMaking changes for asset versioning\n" unless ($quiet); WebGUI::SQL->write("create table assetVersionTag ( diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 246327aa1..8916635c3 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -34,6 +34,10 @@ uploadsPath = /data/WebGUI/www/uploads #fileCacheRoot=/path/to/cache +# Tell WebGUI how big to let the file cache grow in bytes. + +fileCacheSizeLimit=100000000 + # Support for the memcached distributed caching system. # See http://www.danga.com/memcached/ for details on memcached. # Uncomment this and point it to your memcached server(s). Use a diff --git a/lib/WebGUI/Asset/Wobject/Article.pm b/lib/WebGUI/Asset/Wobject/Article.pm index 8319de7c1..4e438bff2 100644 --- a/lib/WebGUI/Asset/Wobject/Article.pm +++ b/lib/WebGUI/Asset/Wobject/Article.pm @@ -106,19 +106,20 @@ sub getIndexerParams { sql => "select Article.assetId, Article.linkTitle, Article.linkURL, - asset.title, - asset.menuTitle, - asset.url, + assetData.title, + assetData.menuTitle, + assetData.url, asset.className, - asset.ownerUserId, - asset.groupIdView, - asset.synopsis, + assetData.ownerUserId, + assetData.groupIdView, + assetData.synopsis, wobject.description from asset, Article left join wobject on wobject.assetId = asset.assetId + left join assetData asset.assetId=assetData.assetId where asset.assetId = Article.assetId - and asset.startDate < $now - and asset.endDate > $now", + and assetData.startDate < $now + and assetData.endDate > $now", fieldsToIndex => ["linkTitle" ,"linkURL","title","menuTitle","url","synopsis","description" ], contentType => 'content', url => 'WebGUI::URL::gateway($data{url})', diff --git a/lib/WebGUI/Asset/Wobject/IndexedSearch/Search.pm b/lib/WebGUI/Asset/Wobject/IndexedSearch/Search.pm index 412ed6d71..8bdd35d90 100644 --- a/lib/WebGUI/Asset/Wobject/IndexedSearch/Search.pm +++ b/lib/WebGUI/Asset/Wobject/IndexedSearch/Search.pm @@ -66,7 +66,7 @@ These methods are available from this package: sub _recurseCrumbTrail { my ($sth, %data, $output); tie %data, 'Tie::CPHash'; - %data = WebGUI::SQL->quickHash("select assetId,parentId,menuTitle,url from asset where assetId=".quote($_[0])); + %data = WebGUI::SQL->quickHash("select asset.assetId,asset.parentId,assetData.menuTitle,asset.url from asset left join assetData on asset.assetId=assetData.assetId where asset.assetId=".quote($_[0])." group by assetData.assetId order by assetData.revisionDate desc"); if ($data{assetId}) { $output .= _recurseCrumbTrail($data{parentId}); } diff --git a/lib/WebGUI/Cache/FileCache.pm b/lib/WebGUI/Cache/FileCache.pm index 5603f3f0d..f8126a170 100644 --- a/lib/WebGUI/Cache/FileCache.pm +++ b/lib/WebGUI/Cache/FileCache.pm @@ -14,7 +14,7 @@ package WebGUI::Cache::FileCache; =cut -use Cache::FileCache; +use Cache::SizeAwareFileCache; use HTTP::Headers; use HTTP::Request; @@ -136,7 +136,7 @@ sub new { auto_purge_on_set=>1 ); $options{cache_root} = $session{config}{fileCacheRoot} if ($session{config}{fileCacheRoot}); - $cache = new Cache::FileCache(\%options); + $cache = new Cache::SizeAwareFileCache(\%options); bless {_cache => $cache, _key => $key}, $class; } @@ -197,6 +197,25 @@ sub setByHTTP { return $response->content; } +#------------------------------------------------------------------- + +=head2 shrink ( [ size ] ) + +Reduces the cache down to a specific size to conserve filesystem space. + +=head3 size + +A size to shrink the cache to in bytes. Defaults to the fileCacheSizeLimit variable in the config file. + +=cut + +sub shrink { + my $self = shift; + my $size = shift || $session{config}{fileCacheSizeLimit} || 10000000; + $self->{_cache}->limit_size($size); +} + + #------------------------------------------------------------------- =head2 stats ( ) diff --git a/sbin/Hourly/CleanFileCache.pm b/sbin/Hourly/CleanFileCache.pm new file mode 100644 index 000000000..67d1e3c85 --- /dev/null +++ b/sbin/Hourly/CleanFileCache.pm @@ -0,0 +1,24 @@ +package Hourly::CleanFileCache; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2005 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::Session; +use WebGUI::Cache::FileCache; + +#------------------------------------------------------------------- +sub process { + my $cache = WebGUI::Cache::FileCache->new; + $cache->shrink; +} + +1; +