Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Aaron Blake 2 posts 73 karma points
    Jun 21, 2017 @ 22:11
    Aaron Blake
    0

    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;
        }
      }
    }
    
  • Damon 217 posts 288 karma points
    Jul 13, 2017 @ 14:00
    Damon
    0

    Hi,

    I have also noticed this issue.

    Umbraco 7.6.1

    Forms 6.0.2

    Does anyone have a fix for this?

    Thanks!

  • Aaron Blake 2 posts 73 karma points
    Jul 13, 2017 @ 19:52
    Aaron Blake
    1

    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:

    • 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.

    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.

  • Ahmed Ossama 1 post 71 karma points
    Jul 28, 2017 @ 02:27
    Ahmed Ossama
    0

    Aaron, you saved my day, thanks a lot bro. for your solution

  • Paul Bordine 1 post 21 karma points
    Aug 04, 2017 @ 18:05
    Paul Bordine
    0

    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.

  • Cliff Fenwick Gibb 3 posts 74 karma points
    Sep 27, 2017 @ 21:22
    Cliff Fenwick Gibb
    0

    Hello,

    The nightly build within UmbracoForms.Package.6.0.4-alpha-20170927-001.zip fixes this issue.

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft