Fix 10939, commit with approval breaks on assets with autocommit children, Post, Story, Wiki, Event, etc.
Encapsulate a new method to get a fresh asset from the db. With tests.
This commit is contained in:
parent
2cf67ecba4
commit
2948e68781
4 changed files with 53 additions and 16 deletions
|
|
@ -26,6 +26,7 @@
|
|||
- relabel Help in the Admin Console to Template Help
|
||||
- fixed #10928: EMS Print Ticket -- Time not processed for timezone
|
||||
- fixed #10889: Old Matrixs break for Admin users
|
||||
- fixed #10939: Commit with Approval workflow does not show confirmation screen
|
||||
|
||||
7.7.19
|
||||
- fixed #10838: Forwarded forum post email to new CS adds reply to original thread
|
||||
|
|
|
|||
|
|
@ -346,6 +346,26 @@ sub checkView {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 cloneFromDb ( )
|
||||
|
||||
Fetches a new fresh clone of this object from the database. Often used after
|
||||
calling commit on version tags.
|
||||
|
||||
Returns the new Asset object.
|
||||
|
||||
=cut
|
||||
|
||||
sub cloneFromDb {
|
||||
my $self = shift;
|
||||
return WebGUI::Asset->new($self->session,
|
||||
$self->getId,
|
||||
$self->get('className'),
|
||||
$self->get('revisionDate')
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, [ definition ] )
|
||||
|
||||
Basic definition of an Asset. Properties, default values. Returns an array reference containing tableName,className,properties
|
||||
|
|
@ -2784,11 +2804,12 @@ sub www_editSave {
|
|||
$object->updateHistory("edited");
|
||||
|
||||
# we handle auto commit assets here in case they didn't handle it themselves
|
||||
$session->log->warn('pre object isa'. ref $object);
|
||||
if ($object->getAutoCommitWorkflowId) {
|
||||
$session->log->warn('got autocommit workflow id');
|
||||
$object->requestAutoCommit;
|
||||
#Since the version tag makes new objects, fetch a fresh one here.
|
||||
#Note, this workaround can still fail, if WebGUI hands off back to spectre.
|
||||
$object = WebGUI::Asset->new($session, $object->getId, $object->get('className'));
|
||||
$object = $object->cloneFromDb;
|
||||
}
|
||||
# else, try to to auto commit
|
||||
else {
|
||||
|
|
@ -2804,9 +2825,10 @@ sub www_editSave {
|
|||
elsif ($commitStatus eq 'commit') {
|
||||
##Commit was successful. Update the local object cache so that it will no longer
|
||||
##register as locked.
|
||||
$self->{_properties}{isLockedBy} = $object->{_properties}{isLockedBy} = undef;
|
||||
$object = $object->cloneFromDb;
|
||||
}
|
||||
}
|
||||
$session->log->warn('post object isa'. ref $object);
|
||||
|
||||
# Handle "saveAndReturn" button
|
||||
if ( $session->form->process( "saveAndReturn" ) ne "" ) {
|
||||
|
|
@ -2814,23 +2836,23 @@ sub www_editSave {
|
|||
}
|
||||
|
||||
# Handle "proceed" form parameter
|
||||
my $proceed = $self->session->form->process('proceed');
|
||||
my $proceed = $session->form->process('proceed');
|
||||
if ($proceed eq "manageAssets") {
|
||||
$self->session->asset($object->getParent);
|
||||
return $self->session->asset->www_manageAssets;
|
||||
$session->asset($object->getParent);
|
||||
return $session->asset->www_manageAssets;
|
||||
}
|
||||
elsif ($proceed eq "viewParent") {
|
||||
$self->session->asset($object->getParent);
|
||||
return $self->session->asset->www_view;
|
||||
$session->asset($object->getParent);
|
||||
return $session->asset->www_view;
|
||||
}
|
||||
elsif ($proceed eq "goBackToPage" && $self->session->form->process('returnUrl')) {
|
||||
$self->session->http->setRedirect($self->session->form->process("returnUrl"));
|
||||
elsif ($proceed eq "goBackToPage" && $session->form->process('returnUrl')) {
|
||||
$session->http->setRedirect($session->form->process("returnUrl"));
|
||||
return undef;
|
||||
}
|
||||
elsif ($proceed ne "") {
|
||||
my $method = "www_".$self->session->form->process("proceed");
|
||||
$self->session->asset($object);
|
||||
return $self->session->asset->$method();
|
||||
my $method = "www_".$session->form->process("proceed");
|
||||
$session->asset($object);
|
||||
return $session->asset->$method();
|
||||
}
|
||||
|
||||
$session->asset($object->getContainer);
|
||||
|
|
|
|||
|
|
@ -889,9 +889,9 @@ sub www_editDuplicate {
|
|||
# Auto-commit our revision if necessary
|
||||
# TODO: This needs to be handled automatically somehow...
|
||||
my $status = WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
|
||||
##Force the locked by tag
|
||||
##get a fresh object from the database
|
||||
if ($status eq 'commit') {
|
||||
$newTemplate->{_properties}{isLockedBy} = undef;
|
||||
$newTemplate = $newTemplate->cloneFromDb;
|
||||
}
|
||||
last DEF;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ $canViewMaker->prepare(
|
|||
},
|
||||
);
|
||||
|
||||
plan tests => 113
|
||||
plan tests => 115
|
||||
+ scalar(@fixIdTests)
|
||||
+ scalar(@fixTitleTests)
|
||||
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
|
||||
|
|
@ -874,6 +874,20 @@ is($testVersionTag->get('isCommitted'),1,'parent asset is now committed');
|
|||
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
|
||||
is($childVersionTag->get('isCommitted'),1,'child asset is now committed');
|
||||
|
||||
################################################################
|
||||
#
|
||||
# cloneFromDb
|
||||
#
|
||||
################################################################
|
||||
|
||||
my $assetToCommit = $defaultAsset->addChild({ className => 'WebGUI::Asset::Snippet', title => 'Snippet to commit and clone from db', });
|
||||
my $cloneTag = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->tagsToRollback($cloneTag);
|
||||
$cloneTag->commit;
|
||||
is($assetToCommit->get('status'), 'pending', 'cloneFromDb: local asset is still pending');
|
||||
$assetToCommit = $assetToCommit->cloneFromDb;
|
||||
is($assetToCommit->get('status'), 'approved', '... returns fresh, commited asset from the db');
|
||||
|
||||
##Return an array of hashrefs. Each hashref describes a test
|
||||
##for the fixId method.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue