Skip to content
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/
@@ -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)

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

# upgrade functions go here

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) {
##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) {
@{$metaEntry}{qw/value assetId fieldId/}, $revisionDate,
##Insert a new one
else {
@{$metaEntry}{qw/assetId fieldId value/}, $revisionDate,
$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.