added automatic purging of old asset revisions
This commit is contained in:
parent
e7d282c730
commit
eb3115d3f9
7 changed files with 125 additions and 24 deletions
|
|
@ -13,7 +13,6 @@ package Hourly::DeleteExpiredClipboard;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
|
|
@ -21,9 +20,9 @@ use WebGUI::SQL;
|
|||
sub process {
|
||||
if ($session{config}{DeleteExpiredClipboard_offset} ne "") {
|
||||
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredClipboard_offset}));
|
||||
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='clipboard' and lastUpdated <".$expireDate);
|
||||
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='clipboard' and stateChanged <".$expireDate);
|
||||
while (my ($id, $class) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($id,$class);
|
||||
my $asset = WebGUI::Asset->new($id,$class);
|
||||
$asset->trash;
|
||||
}
|
||||
$sth->finish;
|
||||
|
|
|
|||
35
sbin/Hourly/DeleteExpiredRevisions.pm
Normal file
35
sbin/Hourly/DeleteExpiredRevisions.pm
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package Hourly::DeleteExpiredRevisions;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-----------------------------------------
|
||||
sub process {
|
||||
if ($session{config}{DeleteExpiredRevisions_offset} ne "") {
|
||||
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredRevisions_offset}));
|
||||
my $sth = WebGUI::SQL->read("select assetData.assetId,asset.className,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.revisionDate<".$expireDate." order by assetData.revisionDate asc");
|
||||
while (my ($id, $class, $version) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->new($id,$class,$version);
|
||||
if ($asset->getRevisionCount("approved") > 1) {
|
||||
$asset->purgeRevision;
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -13,7 +13,6 @@ package Hourly::DeleteExpiredTrash;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
|
|
@ -21,9 +20,9 @@ use WebGUI::SQL;
|
|||
sub process {
|
||||
if ($session{config}{DeleteExpiredTrash_offset} ne "") {
|
||||
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredTrash_offset}));
|
||||
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='trash' and lastUpdated <".$expireDate);
|
||||
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='trash' and stateChanged <".$expireDate);
|
||||
while (my ($id, $class) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($id,$class);
|
||||
my $asset = WebGUI::Asset->new($id,$class);
|
||||
$asset->purge;
|
||||
}
|
||||
$sth->finish;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ sub process {
|
|||
my $offset = $session{config}{TrashExpiredContent_offset};
|
||||
if ($offset ne "") {
|
||||
my $epoch = time()-(86400*$offset);
|
||||
my $sth = WebGUI::SQL->read("select assetId,className from asset where endDate<".$epoch);
|
||||
while (my ($assetId, $class) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($assetId,$class);
|
||||
my $sth = WebGUI::SQL->read("select asset.assetId,asset.className,max(assetData.revisionDate) from asset left join assetData on
|
||||
asset.assetId=assetData.assetId where assetData.endDate<".$epoch." and assetData.status<>'pending' group by asset.assetData");
|
||||
while (my ($assetId, $class, $version) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->new($assetId,$class,$version);
|
||||
$asset->trash;
|
||||
}
|
||||
$sth->finish;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue