Skip to content
Permalink
Browse files

Fix metaData revisionDates that were left as 0 from upgrades. Thanks …

…to Dale Trexe for the script which inspired this upgrade sub. Fixes bug #12339.
  • Loading branch information...
perlDreamer committed Aug 30, 2012
1 parent 93f583d commit 4f74c4cd3e3b0916d5e46847795c6869abe24fd2
Showing with 58 additions and 0 deletions.
  1. +2 −0 docs/changelog/7.x.x.txt
  2. +56 −0 docs/upgrades/upgrade_7.10.26-7.10.27.pl
@@ -2,6 +2,8 @@
- fixed #12379: userImport documentation error
- fixed #12382: WebGUI::Crud does not work with all form types
- fixed: Threads with no posts return the wrong lastReply data.
- fixed #12339: Upgrade to 7.10 causes metadata values to "disappear" (Dale Trexel)


7.10.26
- fixed: Template diagnostics when called without a session asset.
@@ -31,10 +31,66 @@ BEGIN
my $session = start(); # this line required

# upgrade functions go here
fixMetaDataRevisionDates($session);

finish($session); # this line required


#----------------------------------------------------------------------------
# Describe what our function does
sub fixMetaDataRevisionDates {
my $session = shift;
print "\tCheck to see if metaData has bad revision dates... " unless $quiet;
my $getMeta0 = $session->db->read(
'SELECT fieldId, assetId, value from metaData_values where revisionDate=0'
);
my $getRevisionDates = $session->db->prepare(
'select revisionDate from assetData where assetId=? order by revisionDate'
);
my $getMetaValue = $session->db->prepare(
'select value from metaData_values where assetId=? and fieldId=? and revisionDate=?'
);
my $updateMetaValue = $session->db->prepare(
'UPDATE metaData_values set value=? where assetId=? AND fieldId=? and revisionDate=?'
);
my $insertMetaValue = $session->db->prepare(
'INSERT INTO metaData_values (assetId, fieldId, value, revisionDate) VALUES (?,?,?,?)'
);
##Get each metaData_value entry
METAENTRY: while (my $metaEntry = $getMeta0->hashRef) {
$getRevisionDates->execute([$metaEntry->{assetId}]);
##Get all revisionDates for the asset in that entry
REVISIONDATE: while (my ($revisionDate) = $getRevisionDates->array) {
##Find the metaData value for that revisionDate
$getMetaValue->execute([$metaEntry->{assetId}, $metaEntry->{fieldId}, $revisionDate, ]);
my ($metaValue) = $getMetaValue->array;
##If that matches the current entry, we're done with this revisionDate
next REVISIONDATE if $metaValue eq $metaEntry->{value};
##It doesn't match, so we have to fix it.
##Update a bad entry
if (defined $metaValue) {
$updateMetaValue->execute([
@{$metaEntry}{qw/value assetId fieldId/}, $revisionDate,
]);
}
##Insert a new one
else {
$insertMetaValue->execute([
@{$metaEntry}{qw/assetId fieldId value/}, $revisionDate,
]);
}
}
}
$getMeta0->finish;
$getRevisionDates->finish;
$getMetaValue->finish;
$insertMetaValue->finish;
$updateMetaValue->finish;
$session->db->write('delete from metaData_values where revisionDate=0');
print "DONE!\n" unless $quiet;
}


#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {

0 comments on commit 4f74c4c

Please sign in to comment.
You can’t perform that action at this time.