fixed addRevsion problem

This commit is contained in:
JT Smith 2005-08-17 20:56:06 +00:00
parent f65bcbf74d
commit 9b37deeba2
3 changed files with 30 additions and 2 deletions

View file

@ -11,6 +11,8 @@
- fixed more arrayed Form parameters in www_editMetaDataField (mwilson)
- fixed a bunch more errors in the new date field - (mwilson)
- fixed a fatal error in whatNext.pm (mwilson)
- Fixed a bug in the new versioning system where new revisions would sometimes
not get their properties copied from the previous revision.
6.7.0

View file

@ -1,5 +1,7 @@
my $toVersion = "6.7.1";
$|=1; #disable output buffering
use lib "../../lib";
use File::Path;
use Getopt::Long;
@ -24,7 +26,7 @@ WebGUI::Session::refreshUserInfo(3);
WebGUI::SQL->write("insert into webguiVersion values (".quote($toVersion).",'upgrade',".time().")");
fixForumRichEdit();
fixMissingThreadIds();
WebGUI::Session::close();
@ -38,3 +40,26 @@ sub fixForumRichEdit {
}
#-------------------------------------------------
sub fixMissingThreadIds {
print "\tFixing missing thread ids.\n" unless ($quiet);
my $sth = WebGUI::SQL->read("select assetId from Post where threadId=''");
while (my ($assetId) = $sth->array) {
print $assetId."\t";
my $threadId = getThreadId($assetId);
print $threadId."\n";
my $sql = "update Post set threadId=".quote($threadId)." where assetId=".quote($assetId);
#print $sql."\n";
WebGUI::SQL->write($sql);
}
$sth->finish;
}
#-------------------------------------------------
sub getThreadId {
my $assetId = shift;
my ($parentId, $className) = WebGUI::SQL->quickArray("select parentId, className from asset where assetId=".quote($assetId));
return $assetId if ($className eq 'WebGUI::Asset::Post::Thread');
return undef if ($parentId eq 'PBasset000000000000001');
return getThreadId($parentId);
}

View file

@ -68,7 +68,8 @@ sub addRevision {
}
my $newVersion = WebGUI::Asset->new($self->getId, $self->get("className"), $now);
$newVersion->updateHistory("created revision");
$newVersion->update($properties);
$newVersion->update($self->get);
$newVersion->update($properties) if ($properties);
$newVersion->setVersionLock unless ($session{setting}{autoCommit});
return $newVersion;
}