Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete form records programmatically in background job #779

Closed
MMartinezMusterd opened this issue May 30, 2022 · 1 comment
Closed

Comments

@MMartinezMusterd
Copy link

When trying to delete form records in a background job (Hangfire in my case), IRecordService.Delete() throws a null reference exception.

Reproduction

Bug summary

See stacktrace below. RecordService.GetUsernameOfCurrentUser() doesn't mind if backOfficeSecurity.CurrentUser is null, but if backOfficeSecurity itself is null, presumably because there is no HttpContext available for the backoffice security accessor, an exception is thrown and the record is not deleted.

Specifics

Forms version
Tested in 9.4.1 and 9.3

Stacktrace
at Umbraco.Forms.Core.Services.RecordService.GetUsernameOfCurrentUser() at Umbraco.Forms.Core.Services.RecordService.Delete(Record record, Form form)

Steps to reproduce

Call IRecordService.Delete() from a Hangfire task

Possible fix

Perform the null check on backOfficeSecurity as well:
image

@AndyButland
Copy link

Thanks, your diagnosis looks correct to me. I've fixed up this null check for V10 and for a patch of V9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants