more bug fixes

This commit is contained in:
JT Smith 2005-02-23 22:03:54 +00:00
parent 938d6b5d78
commit 90d124de32
6 changed files with 23 additions and 78 deletions

View file

@ -28,6 +28,10 @@ save you many hours of grief.
still being upgraded. Each site will have a maintenance
message displayed until its upgrade is complete.
* The EmptyTrash scheduler plugin has been removed since there's no
need for it with the more useful DeleteExpiredTrash module in
place.
* This upgrade process will run for a very long time and output a
lot of debug information which will be useful if something
goes wrong. You may wish to pipe the debug info to a log

View file

@ -18,12 +18,10 @@ use WebGUI::SQL;
#-----------------------------------------
sub process {
return ""; # disabled for the time being
my $epoch = WebGUI::DateTime::time();
my $a = WebGUI::SQL->read("select forumId,archiveAfter,masterForumId from forum");
my $a = WebGUI::SQL->read("select assetId,archiveAfter,masterForumId from forum");
while (my $forum = $a->hashRef) {
if ($forum->{masterForumId}) {
($forum->{archiveAfter}) = WebGUI::SQL->quickArray("select archiveAfter from forum where masterForumId=".quote($forum->{masterForumId}));
}
my $archiveDate = $epoch - $forum->{archiveAfter};
my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".quote($forum->{forumId})." and lastPostDate<$archiveDate");
while (my ($threadId) = $b->array) {

View file

@ -12,8 +12,8 @@ package Hourly::DeleteExpiredClipboard;
use strict;
use WebGUI::Asset;
use WebGUI::DateTime;
use WebGUI::Page;
use WebGUI::Session;
use WebGUI::SQL;
@ -21,15 +21,12 @@ use WebGUI::SQL;
sub process {
if ($session{config}{DeleteExpiredClipboard_offset} ne "") {
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredClipboard_offset}));
WebGUI::ErrorHandler::audit("moving expired clipboard items to trash");
my $sth = WebGUI::SQL->read("select pageId from page where parentId=2 and bufferDate <".$expireDate);
while (my ($pageId) = $sth->array) {
my $page = WebGUI::Page->new($pageId);
$page->delete;
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='clipboard' and lastUpdated <".$expireDate);
while (my ($id, $class) = $sth->array) {
my $asset = WebGUI::Asset->newByDynamicClass($id,$class);
$asset->trash;
}
$sth->finish;
WebGUI::SQL->write("update wobject set pageId=3, bufferPrevId=2, bufferDate=" .WebGUI::DateTime::time()
." where pageId=2 and bufferDate < ". $expireDate );
}
}

View file

@ -12,43 +12,21 @@ package Hourly::DeleteExpiredTrash;
use strict;
use WebGUI::Asset;
use WebGUI::DateTime;
use WebGUI::Page;
use WebGUI::Session;
use WebGUI::SQL;
#-----------------------------------------
sub process {
if ($session{config}{DeleteExpiredTrash_offset} ne "") {
my (%properties, $base, $extended, $b, $w, $cmd, $purgeDate, $a, $pageId);
tie %properties, 'Tie::CPHash';
$purgeDate = (WebGUI::DateTime::time()-(86400*$session{config}{DeleteExpiredTrash_offset}));
# Delete wobjects
$b = WebGUI::SQL->read("select * from wobject where pageId=3 and bufferDate<" . $purgeDate);
while ($base = $b->hashRef) {
$extended = WebGUI::SQL->quickHashRef("select * from ".$base->{namespace}."
where wobjectId=".quote($base->{wobjectId}));
%properties = (%{$base}, %{$extended});
$cmd = "WebGUI::Wobject::".$properties{namespace};
$w = $cmd->new(\%properties);
WebGUI::ErrorHandler::audit("purging expired wobject ". $base->{wobjectId} ." from trash");
$w->purge;
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredTrash_offset}));
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='trash' and lastUpdated <".$expireDate);
while (my ($id, $class) = $sth->array) {
my $asset = WebGUI::Asset->newByDynamicClass($id,$class);
$asset->purge;
}
$b->finish;
# Delete pages and all subpages
$a = WebGUI::SQL->read("select pageId from page where parentId=3 and bufferDate<" . $purgeDate);
while (($pageId) = $a->array) {
WebGUI::ErrorHandler::audit("purging expired page ". $pageId ." from trash");
WebGUI::Operation::Trash::_recursePageTree($pageId);
WebGUI::Operation::Trash::_purgeWobjects($pageId);
my $page = WebGUI::Page->new($pageId);
$page->purge;
}
$a->finish;
$sth->finish;
}
}

View file

@ -1,31 +0,0 @@
package Hourly::EmptyTrash;
#-------------------------------------------------------------------
# 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::DateTime;
use WebGUI::Operation::Trash;
use WebGUI::Session;
use WebGUI::SQL;
#-----------------------------------------
sub process {
my @date = WebGUI::DateTime::localtime(WebGUI::DateTime::time());
if ($date[1] == $session{config}{EmptyTrash_day} && $date[4] == 1) { # only occurs at 1am on the day in question.
WebGUI::ErrorHandler::audit("emptying system trash");
WebGUI::Operation::Trash::_recursePageTree(3);
WebGUI::Operation::Trash::_purgeWobjects(3);
}
}
1;

View file

@ -11,8 +11,8 @@ package Hourly::TrashExpiredContent;
#-------------------------------------------------------------------
use strict;
use WebGUI::Asset;
use WebGUI::DateTime;
use WebGUI::Page;
use WebGUI::Session;
use WebGUI::SQL;
@ -21,13 +21,12 @@ sub process {
my $offset = $session{config}{TrashExpiredContent_offset};
if ($offset ne "") {
my $epoch = time()-(86400*$offset);
my $sth = WebGUI::SQL->read("select pageId from page where endDate<".$epoch);
while (my ($pageId) = $sth->array) {
my $page = WebGUI::Page->new($pageId);
$page->delete;
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);
$asset->trash;
}
$sth->finish;
WebGUI::SQL->write("update wobject set pageId=3, endDate=endDate+31536000 where endDate<".$epoch);
}
}