lots of bug fixes and a new upgrade feature
This commit is contained in:
parent
5e9652d873
commit
c76829a4e3
8 changed files with 97 additions and 18 deletions
|
|
@ -6,6 +6,8 @@
|
|||
- Converted site maps to navigation assets.
|
||||
- Converted file managers to layout assets with file and image assets
|
||||
attached.
|
||||
- Added a new upgrade mechanism that will display a maintenence message
|
||||
during upgrades. No need to set up anything special for this any longer.
|
||||
- Added AssetProxy macro, which replaces the Navigation, I, Snippet, and File
|
||||
macros.
|
||||
- Added Folder asset type.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,13 @@ save you many hours of grief.
|
|||
|
||||
6.3.0
|
||||
--------------------------------------------------------------------
|
||||
* 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
|
||||
file like this:
|
||||
|
||||
perl upgrade.pl --yourcommandlineoptions > /tmp/upgrade.log
|
||||
|
||||
* If you're using languages other than English, you'll need to get
|
||||
new versions of those language files before upgrading. The
|
||||
language file format has a new requirement. Also, the
|
||||
|
|
|
|||
13
docs/maintenance.html
Normal file
13
docs/maintenance.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Site Down For Maintenance</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Maintenance</h1>
|
||||
<p>
|
||||
This site is currently undergoing maintenance. Please check back again shortly.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -171,17 +171,6 @@ walkTree('0','PBasset000000000000001','000001','2');
|
|||
mapProductCollateral();
|
||||
|
||||
print "\t\tMaking second round of table structure changes\n" unless ($quiet);
|
||||
foreach my $namespace (@allWobjects) {
|
||||
if (isIn($namespace, @wobjects)) {
|
||||
WebGUI::SQL->write("alter table ".$namespace." drop column wobjectId");
|
||||
WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)");
|
||||
} elsif (isIn($namespace, qw(Navigation Layout))) {
|
||||
# do nothing
|
||||
} else {
|
||||
WebGUI::SQL->write("alter table ".$namespace." drop primary key");
|
||||
WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)");
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->write("alter table WobjectProxy add column shortcutToAssetId varchar(22) not null");
|
||||
my $sth = WebGUI::SQL->read("select proxiedWobjectId from WobjectProxy");
|
||||
while (my ($wobjectId) = $sth->array) {
|
||||
|
|
@ -189,6 +178,21 @@ while (my ($wobjectId) = $sth->array) {
|
|||
WebGUI::SQL->write("update WobjectProxy set shortcutToAssetId=".quote($assetId)." where wobjectId=".quote($wobjectId));
|
||||
}
|
||||
$sth->finish;
|
||||
foreach my $namespace (@allWobjects) {
|
||||
if (isIn($namespace, qw(SiteMap USS FileManager))) {
|
||||
# do nothing because these are going away
|
||||
} elsif (isIn($namespace, @wobjects)) {
|
||||
WebGUI::SQL->write("delete from ".$namespace." where assetId is null or assetId = ''"); # protect ourselves from crap
|
||||
WebGUI::SQL->write("alter table ".$namespace." drop column wobjectId");
|
||||
WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)");
|
||||
} elsif (isIn($namespace, qw(Navigation Layout Collaboration Folder))) {
|
||||
# do nothing because these are new
|
||||
} else {
|
||||
WebGUI::SQL->write("delete from ".$namespace." where assetId is null or assetId = ''"); # protect ourselves from crap
|
||||
WebGUI::SQL->write("alter table ".$namespace." drop primary key");
|
||||
WebGUI::SQL->write("alter table ".$namespace." add primary key (assetId)");
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->write("alter table WobjectProxy drop proxiedWobjectId");
|
||||
WebGUI::SQL->write("alter table WobjectProxy change proxiedTemplateId overrideTemplateId varchar(22) not null");
|
||||
WebGUI::SQL->write("alter table WobjectProxy change proxyByCriteria shortcutByCriteria int not null");
|
||||
|
|
@ -1598,12 +1602,12 @@ sub walkTree {
|
|||
WebGUI::SQL->write("update wobject set namespace='Collaboration' where wobjectId=".quote($wobject->{wobjectId}));
|
||||
print "\t\t\tMigrating submissions for USS ".$wobject->{wobjectId}."\n" unless ($quiet);
|
||||
my $ussId = $namespace->{USS_id};
|
||||
my $sth = WebGUI::SQL->read("select * from USS_submission where USS_id=".quote($ussId));
|
||||
my $usssubrank = 1;
|
||||
my $collabReplyCounter;
|
||||
my $collabViewCounter;
|
||||
my $collabThreadCounter;
|
||||
my %oldestForumPost;
|
||||
my $sth = WebGUI::SQL->read("select * from USS_submission where USS_id=".quote($ussId));
|
||||
while (my $submission = $sth->hashRef) {
|
||||
$collabThreadCounter++;
|
||||
$collabViewCounter += $submission->{views};
|
||||
|
|
@ -1662,9 +1666,9 @@ sub walkTree {
|
|||
subscriptionGroupId=>$threadSubscriptionGroup->groupId
|
||||
}, undef, $id);
|
||||
my %oldestThreadPost;
|
||||
my $posts = WebGUI::SQL->read("select forumPost.* from forumPost left join forumThread on forumPost.forumThreadId=forumThread.forumThreadId where forumId=".quote($submission->{forumId}));
|
||||
my $postRank = 1;
|
||||
my $threadReplyCounter;
|
||||
my $posts = WebGUI::SQL->read("select forumPost.* from forumPost left join forumThread on forumPost.forumThreadId=forumThread.forumThreadId where forumId=".quote($submission->{forumId}));
|
||||
while (my $post = $posts->hashRef) {
|
||||
$collabViewCounter += $post->{views};
|
||||
$threadReplyCounter++;
|
||||
|
|
@ -1738,6 +1742,7 @@ sub walkTree {
|
|||
WebGUI::SQL->write("update WobjectProxy set description=".quote($wobject->{description})." where
|
||||
assetId=".quote($wobjectId));
|
||||
} elsif ($wobject->{namespace} eq "MessageBoard") {
|
||||
print "\t\t\tMigrating Message Board forums\n" unless ($quiet);
|
||||
my $forums = WebGUI::SQL->read("select forumId, title, description from MessageBoard_forums where wobjectId=".quote($wobject->{wobjectId})." order by sequenceNumber");
|
||||
my $i = 1;
|
||||
while (my ($fid, $title, $desc) = $forums->array) {
|
||||
|
|
@ -1921,9 +1926,14 @@ sub migrateForum {
|
|||
my $ratingprep = WebGUI::SQL->prepare("insert into Post_rating (assetId, userId, ipAddress, dateOfRating, rating) values (?,?,?,?,?)");
|
||||
print "\t\t\t\t\t Migrating threads for forum $originalId\n";
|
||||
my $threads = WebGUI::SQL->read("select * from forumThread left join forumPost on forumThread.rootPostId=forumPost.forumPostId where
|
||||
forumThread.forumId=".quote($originalId));
|
||||
forumThread.forumId=".quote($originalId)." and forumPost.status<>'deleted'");
|
||||
my $threadRank = 1;
|
||||
while (my ($thread) = $threads->hashRef) {
|
||||
if ($threads->errorCode>0) {
|
||||
print "\t\t\t\tWARNING: There was a problem migrating the threads for $originalId\n";
|
||||
return;
|
||||
}
|
||||
while (($threads->errorCode < 1) && (my ($thread) = $threads->hashRef)) {
|
||||
next if ($thread->{forumThreadId} eq "");
|
||||
print "\t\t\t\t\t\t Migrating thread ".$thread->{forumThreadId}."\n";
|
||||
my $threadLineage = $lineage.sprintf("%06d",$threadRank);
|
||||
my $threadId = WebGUI::SQL->setRow("asset","assetId",{
|
||||
|
|
@ -1979,9 +1989,14 @@ sub migrateForum {
|
|||
# we're going to give up hierarchy during the upgrade for the sake of simplicity
|
||||
print "\t\t\t\t\t\t Migrating posts for thread ".$thread->{forumThreadId}."\n";
|
||||
my %oldestThreadPost;
|
||||
my $posts = WebGUI::SQL->read("select * from forumPost where forumThreadId=".quote($thread->{forumThreadId})." and parentId<>''");
|
||||
my $posts = WebGUI::SQL->read("select * from forumPost where forumThreadId=".quote($thread->{forumThreadId})." and parentId<>'' and forumPost.status<>'deleted'");
|
||||
my $postRank = 1;
|
||||
if ($posts->errorCode>0) {
|
||||
print "\t\t\t\tWARNING: There was a problem migrating the posts for ".$thread->{forumThreadId}."\n";
|
||||
next;
|
||||
}
|
||||
while (my $post = $posts->hashRef) {
|
||||
next if ($thread->{forumPostId} eq "");
|
||||
print "\t\t\t\t\t\t\t Migrating post ".$post->{forumPostId}."\n";
|
||||
my $postId = WebGUI::SQL->setRow("asset","assetId",{
|
||||
assetId=>"new",
|
||||
|
|
@ -2026,6 +2041,7 @@ sub migrateForum {
|
|||
$postRank++;
|
||||
}
|
||||
$posts->finish;
|
||||
print "\t\t\t\t\t\t\t Setting oldest post for thread ".$thread->{forumThreadId}."\n";
|
||||
WebGUI::SQL->setRow("Thread","assetId",{
|
||||
assetId=>$threadId,
|
||||
lastPostId=>$oldestThreadPost{id},
|
||||
|
|
@ -2037,8 +2053,10 @@ sub migrateForum {
|
|||
}
|
||||
$threadRank++;
|
||||
}
|
||||
print "\t\t\t\t WARNING: Couldn't finish processing threads for $originalId because something nasty occured in the database." if ($threads->errorCode > 0);
|
||||
$threads->finish;
|
||||
$ratingprep->finish;
|
||||
print "\t\t\t\t\t\t Setting oldest post for forum ".$originalId."\n";
|
||||
WebGUI::SQL->setRow("Collaboration","assetId",{
|
||||
assetId=>$newId,
|
||||
lastPostId=>$oldestForumPost{id},
|
||||
|
|
@ -2049,6 +2067,9 @@ sub migrateForum {
|
|||
sub fixUrl {
|
||||
my $id = shift;
|
||||
my $url = shift;
|
||||
if (length($url) > 250) {
|
||||
$url = substr($url,220);
|
||||
}
|
||||
$url = WebGUI::Id::generate() unless (defined $url);
|
||||
$url = WebGUI::URL::urlize($url);
|
||||
my ($test) = WebGUI::SQL->quickArray("select url from asset where assetId<>".quote($id)." and url=".quote($url));
|
||||
|
|
|
|||
|
|
@ -53,6 +53,20 @@ sub _processOperations {
|
|||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _upgrading {
|
||||
my $webguiRoot = shift;
|
||||
my $output = WebGUI::HTTP::getHeader();
|
||||
open(FILE,"<".$webguiRoot."/docs/maintenance.html");
|
||||
while (<FILE>) {
|
||||
$output .= $_;
|
||||
}
|
||||
close(FILE);
|
||||
WebGUI::Session::close();
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub page {
|
||||
my $webguiRoot = shift;
|
||||
|
|
@ -61,6 +75,7 @@ sub page {
|
|||
my $assetUrl = shift;
|
||||
my $fastcgi = shift;
|
||||
WebGUI::Session::open($webguiRoot,$configFile,$fastcgi) unless ($useExistingSession);
|
||||
return _upgrading($webguiRoot) if ($session{setting}{specialState} eq "upgrading");
|
||||
my $output = _processOperations();
|
||||
if ($output eq "") {
|
||||
my $asset = WebGUI::Asset->newByUrl($assetUrl);
|
||||
|
|
|
|||
|
|
@ -327,6 +327,7 @@ sub open {
|
|||
$CGI::POST_MAX=-1;
|
||||
$session{cgi} = CGI->new();
|
||||
}
|
||||
return if ($session{setting}{specialState} eq "upgrading");
|
||||
###----------------------------
|
||||
### evironment variables from web server
|
||||
$session{env} = \%ENV;
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ if (opendir (CONFDIR,$confdir)) {
|
|||
print "\nProcessing ".$file.":\n" if ($verbose);
|
||||
my $startTime = time();
|
||||
WebGUI::Session::open($webguiRoot,$file);
|
||||
if ($session{setting}{specialState} eq "upgrading") {
|
||||
print "\nSkipping because this site is undergoing an upgrade.\n" if ($verbose);
|
||||
WebGUI::Session::close();
|
||||
next;
|
||||
}
|
||||
WebGUI::Session::refreshUserInfo(3,$session{dbh});
|
||||
foreach $namespace (keys %plugins) {
|
||||
my $taskTime = time();
|
||||
|
|
|
|||
|
|
@ -171,8 +171,12 @@ foreach my $file (@files) {
|
|||
my $dbh = DBI->connect($config{$file}{dsn},$config{$file}{dbuser},$config{$file}{dbpass});
|
||||
($config{$file}{version}) = WebGUI::SQL->quickArray("select webguiVersion from webguiVersion
|
||||
order by dateApplied desc, webguiVersion desc limit 1",$dbh);
|
||||
unless ($history) {
|
||||
print "\tPreparing site for upgrade.\n" unless ($quiet);
|
||||
$dbh->do("replace into settings (name,value) values ('specialState','upgrading')") unless ($history);
|
||||
rmtree($config->get("uploadsPath").$slash."temp");
|
||||
}
|
||||
$dbh->disconnect;
|
||||
rmtree($config->get("uploadsPath").$slash."temp");
|
||||
} else {
|
||||
delete $config{$file};
|
||||
print "\tSkipping non-MySQL database.\n" unless ($quiet);
|
||||
|
|
@ -206,7 +210,7 @@ opendir(DIR,$upgradesPath) or die "Couldn't open $upgradesPath\n";
|
|||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
foreach my $file (@files) {
|
||||
if ($file =~ /upgrade_(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.(\w+)/) {
|
||||
if ($file =~ /^upgrade_(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.(pl|sql)$/) {
|
||||
if (checkVersion($1)) {
|
||||
if ($3 eq "sql") {
|
||||
print "\tFound upgrade script from $1 to $2.\n" unless ($quiet);
|
||||
|
|
@ -270,6 +274,17 @@ foreach my $config (keys %config) {
|
|||
$config{$config}{version} = $upgrade{$upgrade}{to};
|
||||
$notRun = 0;
|
||||
}
|
||||
print "\tSetting site upgrade completed..." unless ($quiet);
|
||||
my $cmd = $clicmd." -u".$config{$config}{dbuser}." -p".$config{$config}{dbpass};
|
||||
$cmd .= " --host=".$config{$config}{host} if ($config{$config}{host});
|
||||
$cmd .= " --port=".$config{$config}{port} if ($config{$config}{port});
|
||||
$cmd .= " --database=".$config{$config}{db}." -e \"delete from settings where name='upgrading'\"";
|
||||
unless (system($cmd)) {
|
||||
print "OK\n" unless ($quiet);
|
||||
} else {
|
||||
print "Failed!\n" unless ($quiet);
|
||||
fatalError();
|
||||
}
|
||||
}
|
||||
|
||||
if ($notRun) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue