diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 977f35172..6550bb12e 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -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 diff --git a/docs/upgrades/upgrade_6.7.0-6.7.1.pl b/docs/upgrades/upgrade_6.7.0-6.7.1.pl index 6518e0190..7e72cd4a2 100644 --- a/docs/upgrades/upgrade_6.7.0-6.7.1.pl +++ b/docs/upgrades/upgrade_6.7.0-6.7.1.pl @@ -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); +} diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index e365ece5b..881c9d9ad 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -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; }