Cannot delete member with 'Upload' datatype in 7.2.2
I have just upgraded to 7.2.2 in hopes that there would be a magic fix in there somewhere, but alack and alas, no such luck.
The problem is as simple as I stated, I have a number of upload properties for my members and for whatever reason this is causing Umbraco to go sideways when I try to delete members. If I change the upload properties to textstring (I didn't test, but probably any other datatype would work too), the members delete without issue. Change them back to upload and bam no more deleting. I have tried deleting from the backend in the listview, using the action button, and also by calling MemberService.Delete(IMember) but to no avail. Always the same result.
In the backend, this is the message I get when trying to delete a member:
Server error: Contact administrator, see log for full details.
Failed to delete item 9079bddc631147f09605b3e46cf4b4cd
But there is nothing in any log (at least none that I can find...)
In the Firebug console I get a bit more:
When I try with the API call, here is the complete stacktrace that I get:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 24:
Line 25: ms.Delete(m);
Line 26:
Source File: d:\[ Websites ]\Webmatrix\QSI Umbraco 7 MVC\Views\Partials\recruitingToolsMemberCleanup.cshtml Line: 25
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Core.Persistence.Repositories.MemberRepository.PersistDeletedItem(IMember entity) +178
Umbraco.Core.Persistence.Repositories.RepositoryBase`2.PersistDeletedItem(IEntity entity) +49
Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action`1 transactionCompleting) +124
Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() +7
Umbraco.Core.Services.MemberService.Delete(IMember member) +140
ASP._Page_Views_Partials_recruitingToolsMemberCleanup_cshtml.Execute() in d:\[ Websites ]\Webmatrix\QSI Umbraco 7 MVC\Views\Partials\recruitingToolsMemberCleanup.cshtml:25
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +96
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +257
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +93
System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +276
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +108
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName) +31
ASP._Page_Views_RecruitingToolsMemberCleanup_cshtml.Execute() in d:\[ Websites ]\Webmatrix\QSI Umbraco 7 MVC\Views\RecruitingToolsMemberCleanup.cshtml:21
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +96
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +257
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +93
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +294
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +175
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9676252
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237
If there was a way to switch members to a different member type and dump all the custom properties in the move, that would work, but AFAIK that is not possible, but I would be very happy to be wrong.
I am really hoping for a fix here. I have members that I really need to delete but can't, and switching all the upload fields to something else dosen't really seem like a solution as I am pretty sure that doing so would completely FOOBAR all the data stored in those fields for the member accounts that I don't want to delete.
I just had a thought about ten minutes ago as I was driving into work this morning. If I am understanding what I am seeing, the issues is some kind of null error Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. I know that at least in my case, most of the upload fields are empty. I am wondering if that is what the null reference error is...
I am going to do a little testing and see if my theory works. If so, I can imagine some pretty silly workarounds (programatically uploading a file to the upload field prior to deleting via the API) that would at least allow me to delete until the HQ folks can put together a fix. I will report back the results of my testing shortly.
Cheers! I will take you up on that offer if I ever make it down your way.
I just hacked together some code and it seems to work. Just before calling MemberService.Delete(IMember); on the offending member account, I upload a dummy string to each of the upload fields m.SetValue("photo", "foo"); etc... and that seems to do the trick. On my development machine I just looped through a few hundred 'expired' member accounts with this technique and it worked a peach.
So it looks like you don't even need to put 'real' files into the upload fields, just some bit of garbage so that it dosen't fail on the (missing) null reference check. Hopefully that bit of hacky-ness doesn't cause other problems down the road...
Following on from Josh's comment, I fixed my issue by hooking into the member deleting event and setting the property with a value - code below just in case someone needs it!
public class UmbracoEvents : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
MemberService.Deleting += MemberService_Deleting;
}
private void MemberService_Deleting(IMemberService sender, DeleteEventArgs<IMember> e)
{
foreach (var item in e.DeletedEntities)
{
var member = sender.GetById(item.Id);
member.SetValue("profileimage","#");
sender.Save(member,false);
}
}
}
Edit: Actually, you need to set the RaiseEvent flag to false for this to work - snippet updated
Cannot delete member with 'Upload' datatype in 7.2.2
I have just upgraded to 7.2.2 in hopes that there would be a magic fix in there somewhere, but alack and alas, no such luck.
The problem is as simple as I stated, I have a number of upload properties for my members and for whatever reason this is causing Umbraco to go sideways when I try to delete members. If I change the upload properties to textstring (I didn't test, but probably any other datatype would work too), the members delete without issue. Change them back to upload and bam no more deleting. I have tried deleting from the backend in the listview, using the action button, and also by calling
MemberService.Delete(IMember)
but to no avail. Always the same result.In the backend, this is the message I get when trying to delete a member:
But there is nothing in any log (at least none that I can find...)
In the Firebug console I get a bit more:
When I try with the API call, here is the complete stacktrace that I get:
I don't know if it is related, but there do seem to be some others with a similar issue: http://issues.umbraco.org/issue/U4-6113, https://our.umbraco.org/forum/developers/api-questions/60471-Cannot-delete-member-721, and this is the one that made me think to try experimenting with the upload field in the first place https://our.umbraco.org/projects/collaboration/dialogue/general/60604-Unable-to-delete-Dialogue-members.
If there was a way to switch members to a different member type and dump all the custom properties in the move, that would work, but AFAIK that is not possible, but I would be very happy to be wrong.
I am really hoping for a fix here. I have members that I really need to delete but can't, and switching all the upload fields to something else dosen't really seem like a solution as I am pretty sure that doing so would completely FOOBAR all the data stored in those fields for the member accounts that I don't want to delete.
Cheers!
Same here. Tested by changing the upload datatypes to text fields.
I just had a thought about ten minutes ago as I was driving into work this morning. If I am understanding what I am seeing, the issues is some kind of null error
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object
. I know that at least in my case, most of the upload fields are empty. I am wondering if that is what the null reference error is...I am going to do a little testing and see if my theory works. If so, I can imagine some pretty silly workarounds (programatically uploading a file to the upload field prior to deleting via the API) that would at least allow me to delete until the HQ folks can put together a fix. I will report back the results of my testing shortly.
Cheers!
That is indeed the case. Messy work around, but at least we can move forward.
Disco!
My hypothesis was correct. I uploaded a little 40byte file in each upload field and then hit the delete and it worked!
Shot man. Owe you a beer when you come to South Africa.
Anton,
Cheers! I will take you up on that offer if I ever make it down your way.
I just hacked together some code and it seems to work. Just before calling
MemberService.Delete(IMember);
on the offending member account, I upload a dummy string to each of the upload fieldsm.SetValue("photo", "foo");
etc... and that seems to do the trick. On my development machine I just looped through a few hundred 'expired' member accounts with this technique and it worked a peach.So it looks like you don't even need to put 'real' files into the upload fields, just some bit of garbage so that it dosen't fail on the (missing) null reference check. Hopefully that bit of hacky-ness doesn't cause other problems down the road...
I think I'm having the same issue on 7.2.4 (upgraded from 6.2.4). I'm not able to delete a member without an uploaded file.
Also, I'm not able to save a member when I try to upload a file. It works fine when I leave the upload field empty.
Does anyone know if there's a fix for this?
Please vote for this issues in http://issues.umbraco.org/issue/U4-6113
Following on from Josh's comment, I fixed my issue by hooking into the member deleting event and setting the property with a value - code below just in case someone needs it!
Edit: Actually, you need to set the RaiseEvent flag to false for this to work - snippet updated
is working on a reply...