fix: 7.2.3-7.3.0 upgrade now grabs the latest committed version of Events, instead of a random version

fix: 7.2.3-7.3.0 upgrade now does not modify the URL of the Calendars it migrates
This commit is contained in:
Doug Bell 2007-02-16 18:36:43 +00:00
parent efb0109465
commit 11b308df81
3 changed files with 44 additions and 8 deletions

View file

@ -235,12 +235,11 @@ sub migrateCalendars {
$properties->{defaultDate} = delete $properties->{defaultMonth};
#warn "Found calendar ".$properties->{title};
$properties->{className} = "WebGUI::Asset::Wobject::Calendar";
# Add the new asset
my $newAsset = $asset->getParent->addChild($properties);
#warn "Added Calendar ".$newAsset->get("title")." ".$newAsset->get("className");
# Get this calendar's events and change to new parent
my $events = $asset->getLineage(['descendants'],
{
@ -251,14 +250,30 @@ sub migrateCalendars {
#warn "Got lineage";
for my $event (@{$events})
{
for my $event (@{$events}) {
#warn "Got event: $event";
# Add a child to the new calendar using the properties
# from EventsCalendar_event
my %eventProperties = $session->db->quickHash("select * from asset left join assetData on asset.assetId=assetData.assetId left join EventsCalendar_event on asset.assetId = EventsCalendar_event.assetId where asset.assetId = ?",[$event]);
my %eventProperties = $session->db->quickHash("
select
*
from
asset
left join
assetData on asset.assetId=assetData.assetId
left join
EventsCalendar_event on asset.assetId = EventsCalendar_event.assetId and assetData.revisionDate=EventsCalendar_event.revisionDate
where
asset.assetId = ?
and assetData.revisionDate=(
select
max(revisionDate)
from assetData
where assetData.assetId=asset.assetId
and (status='approved' or status='archived')
)
",[$event]);
delete $eventProperties{assetId};
my ($startDate, $startTime) = split / /, WebGUI::DateTime->new(delete $eventProperties{eventStartDate})->toMysql;
@ -283,9 +298,15 @@ sub migrateCalendars {
#warn "Set parents on events";
# Remove the old asset
# Save the old Calendar's URL so we can fix it
my $fixUrl = $asset->get("url");
# Remove the old asset
$asset->purge;
#warn "Purged old calendar";
# Fix the new Calendar's URL
$newAsset->update({ url => $fixUrl });
}
}