Umbraco Forms - Approve record command fails to update record in database - Scope bug
Hi,
There seems to be an bug in the v6.0.1 release of the Umbraco Forms module.
Previously if you enabled moderation on form submissions, when a user submitted a new record, the forms admin could review the record and use the approval command in the Umbraco back office to approve the record.
The approval command seems to be broken in v6.0.1. It looks like the SQL command to update the form record is sent to the database, however the transaction is aborted so the change is never committed.
It looks like the problem lies in the following method:
Umbraco.Forms.Data.Storage.RecordStorage.UpdateRecord
The method uses the ScopeProvider to create a new scope which is used to execute the SQL commands. However the IScope.Complete method is never called, so the transaction is always aborted.
Is there a patch for this bug. Has anyone else come across this issue?
If there is a way to override the Umbraco.Forms.Data.Storage.RecordStorage.UpdateRecord, please let me know so I can resolve the issue.
If further information is required, please let me know.
public Record UpdateRecord(Record record, Form form)
{
using (ApplicationContext.Current.ProfilingLogger.DebugDuration<RecordStorage>(string.Format("Update Record '{0}' for the Form '{1}' with id '{2}'", (object) record.UniqueId, (object) form.Name, (object) form.Id)))
{
using (IScope scope = ApplicationContext.Current.ScopeProvider.CreateScope(IsolationLevel.Unspecified, RepositoryCacheMode.Unspecified, (IEventDispatcher) null, new bool?(), false))
{
record.Updated = DateTime.Now;
scope.Events.Dispatch<RecordEventArgs>(RecordStorage.RecordUpdating, (object) this, new RecordEventArgs(record.State, form, record), "RecordUpdating");
scope.Database.Update((object) record);
Dictionary<Guid, RecordField> dictionary = new Dictionary<Guid, RecordField>();
this._fieldValueStorage.DeleteAllRecordFieldValues(record);
foreach (KeyValuePair<Guid, RecordField> recordField in record.RecordFields)
{
if (recordField.Value.Key == Guid.Empty)
dictionary.Add(recordField.Key, this._storage.InsertRecordField(recordField.Value));
else
dictionary.Add(recordField.Key, this._storage.UpdateRecordField(recordField.Value));
}
record.RecordFields = dictionary;
// scope.Complete() is missing here
return record;
}
}
}
I haven't tested the latest version of Umbraco Forms, however I managed to get around the issue by using a custom workflow actions in the approval stage.
I created two custom workflow actions:
ResetScope
ApproveRecord
Both actions are required for the approve record action to work.
Set the reset scope action as the first one to run in the approval step, add any other custom actions, then add the approve record action at the end.
Umbraco Forms - Approve record command fails to update record in database - Scope bug
Hi,
There seems to be an bug in the v6.0.1 release of the Umbraco Forms module.
Previously if you enabled moderation on form submissions, when a user submitted a new record, the forms admin could review the record and use the approval command in the Umbraco back office to approve the record.
The approval command seems to be broken in v6.0.1. It looks like the SQL command to update the form record is sent to the database, however the transaction is aborted so the change is never committed.
It looks like the problem lies in the following method: Umbraco.Forms.Data.Storage.RecordStorage.UpdateRecord
The method uses the ScopeProvider to create a new scope which is used to execute the SQL commands. However the IScope.Complete method is never called, so the transaction is always aborted.
Is there a patch for this bug. Has anyone else come across this issue? If there is a way to override the Umbraco.Forms.Data.Storage.RecordStorage.UpdateRecord, please let me know so I can resolve the issue.
If further information is required, please let me know.
Hi,
I have also noticed this issue.
Umbraco 7.6.1
Forms 6.0.2
Does anyone have a fix for this?
Thanks!
Hi,
I haven't tested the latest version of Umbraco Forms, however I managed to get around the issue by using a custom workflow actions in the approval stage.
I created two custom workflow actions:
Both actions are required for the approve record action to work.
Set the reset scope action as the first one to run in the approval step, add any other custom actions, then add the approve record action at the end.
The code can be seen here: https://gist.github.com/sonicaab/02a4c0f4056c452a23ad84a9de58a9e1
It's not the best solution, but it works for now.
Hopefully the bug will be fixed soon.
Aaron, you saved my day, thanks a lot bro. for your solution
I am seeing this bug in Forms 6.0.2 as well. It looks like there may be a fix pending: http://issues.umbraco.org/issue/CON-1344.
Hopefully we will see 6.0.3 released very soon.
Hello,
The nightly build within UmbracoForms.Package.6.0.4-alpha-20170927-001.zip fixes this issue.
Cheers
is working on a reply...