U4-5454 - IsApproved is not set correctly in MemberService.Saving event

Created by Petr Snobelt 09 Sep 2014, 11:37:47 Updated by Claus Jensen 29 Jun 2017, 10:33:08

Tags: Unscheduled PR

In MemberService.Saving event member.IsApproved value is always true

Steps to reproduce: Add MemberSavingEvent into App_Code, find any Member try remove IsApproved checkbox and hit save - value in IsApprovedBug variable is always true in my umbraco 7.1.6

using Umbraco.Core; using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Services;

public class MemberSavingEvent : ApplicationEventHandler { public MemberSavingEvent() { MemberService.Saving += MemberServiceOnSaving; }

    private void MemberServiceOnSaving(IMemberService sender, SaveEventArgs<IMember> e)
    {
        foreach (var member in e.SavedEntities)
        {
            bool IsApprovedBug = member.IsApproved; //BUG: Always return true

            var m = ApplicationContext.Current.Services.MemberService.GetById(member.Id);
            var IsApproved = m.IsApproved; //Correct value
        }
    }
}

1 Attachments

Download MemberEvents.cs

Comments

Cristiano Martins 12 Oct 2016, 21:52:30

I'm getting the same issue using v7


Matt Cheale 02 Nov 2016, 19:30:11

I believe this is still happening because you get the log that the umbracoMemberApproved property is not available. I've found this seems to occur if you modify the default Member member-type, once modified the "fixed" properties vanish from the event handlers. Creation of a new member-type doesn't appear to be affected by this.


Matt Cheale 03 Nov 2016, 13:57:19

I've attached a small file that logs the properties of a Member during the MemberService.Saved event. What I've found is:

  • If you change any fixed field, e.g. "umbracoMemberApproved" then the fixed fields are present on the IMember that is passed in.
  • You don't change any fixed field then they are all ommitted from the IMember that is passed in.


Claus Jensen 07 Nov 2016, 10:53:56

PR: https://github.com/umbraco/Umbraco-CMS/pull/1574


Claus Jensen 29 Jun 2017, 08:03:44

Updated PR without breaking changes to the API:

https://github.com/umbraco/Umbraco-CMS/pull/2022


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted: Pull request

Affected versions: 7.5.4

Due in version: 7.6.5

Sprint:

Story Points: 1

Cycle: 2