Merge branch 'master' of git@github.com:plainblack/webgui

This commit is contained in:
Martin Kamerbeek 2009-12-18 12:11:55 +01:00
commit 6bdf5f42ed
7 changed files with 171 additions and 17 deletions

View file

@ -1,3 +1,5 @@
7.8.9
7.8.8
- fixed #11289: Gallery with pending version tag causes search engine indexer to puke.
- fixed #11292: Search function limited to onje search?
@ -11,6 +13,7 @@
- fixed #11297: YUI Rich Editor fails to load when editing Survey in 7.7.27
- fixed #11306: Survey i18n: Loading....
- fixed #11307: Survey i18n #2
- fixed #11295: asset addChild failure when parent is not committed
7.8.7
- fixed #11278: Wrong test for Template::Toolkit in testEnvironment.pl

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,130 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.8.9';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = eval { WebGUI::Asset->getImportNode($session)->importPackage( $storage, { overwriteLatest => 1 } ); };
if ($package eq 'corrupt') {
die "Corrupt package found in $file. Stopping upgrade.\n";
}
if ($@ || !defined $package) {
die "Error during package import on $file: $@\nStopping upgrade\n.";
}
# Turn off the package flag, and set the default flag for templates added
my $assetIds = $package->getLineage( ['self','descendants'] );
for my $assetId ( @{ $assetIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( !$asset ) {
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
next;
}
my $properties = { isPackage => 0 };
if ($asset->isa('WebGUI::Asset::Template')) {
$properties->{isDefault} = 1;
}
$asset->update( $properties );
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -1,7 +1,7 @@
package WebGUI;
our $VERSION = '7.8.8';
our $VERSION = '7.8.9';
our $STATUS = 'beta';

View file

@ -92,7 +92,7 @@ sub addRevision {
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
my $workingTag;
my ($workingTag, $oldWorking);
if ( $autoCommitId ) {
$workingTag
= WebGUI::VersionTag->create( $self->session, {
@ -109,7 +109,9 @@ sub addRevision {
$workingTag = WebGUI::VersionTag->getWorking( $self->session );
}
else {
my $oldWorking = WebGUI::VersionTag->getWorking($self->session, 'noCreate');
$workingTag = WebGUI::VersionTag->new( $self->session, $parentAsset->get('tagId') );
$workingTag->setWorking();
}
}
@ -163,6 +165,7 @@ sub addRevision {
$newVersion->setVersionLock;
$newVersion->update(\%mergedProperties);
$newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId);
$oldWorking->setWorking if $oldWorking;
return $newVersion;
}

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
use Test::More tests => 92; # increment this value for each test you create
use Test::More tests => 93; # increment this value for each test you create
use Test::Deep;
# Test the methods in WebGUI::AssetLineage
@ -526,6 +526,26 @@ $vTag2->commit;
is($deepAsset[41]->getParent->getId, $deepAsset[40]->getId, 'addChild will not create an asset with a lineage deeper than 42 levels');
like($WebGUI::Test::logger_warns, qr/Adding it as a sibling instead/, 'addChild logged a warning about deep assets');
{
my $tag = WebGUI::VersionTag->getWorking($session);
addToCleanup($tag);
my $uncommittedParent = $root->addChild({
className => "WebGUI::Asset::Wobject::Layout",
groupIdView => 7,
ownerUserId => 3,
title => "Uncommitted Parent",
});
$tag->leaveTag;
my $parent = WebGUI::Asset->newPending($session, $uncommittedParent->getId);
my $floater = $parent->addChild({
className => "WebGUI::Asset::Snippet",
groupIdView => 7,
ownerUserId => 3, #For coverage on addChild properties
title => "Child of uncommitted parent",
});
is $parent->get('tagId'), $floater->get('tagId'), 'addChild: with uncommitted parent, adds child and puts it into the same tag as the parent';
}
TODO: {
local $TODO = "Tests to make later";
ok(0, 'addChild');