U4-3437 - Deleting a macro with parameters causes YSOD

Created by Shannon Deminick 07 Nov 2013, 04:14:28 Updated by Shannon Deminick 07 Nov 2013, 04:16:20

The issue is at the repo layer since we're not first deleting parameters

Server Error in '/' Application.

The DELETE statement conflicted with the REFERENCE constraint "FK_cmsMacroProperty_cmsMacro_id". The conflict occurred in database "v7new", table "dbo.cmsMacroProperty", column 'macro'. The statement has been terminated.

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.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK_cmsMacroProperty_cmsMacro_id". The conflict occurred in database "v7new", table "dbo.cmsMacroProperty", column 'macro'. The statement has been terminated.

Source Error:

Line 244: if (e.Cancel == false) Line 245: { Line 246: ApplicationContext.Current.Services.MacroService.Delete(MacroItem); Line 247: Line 248: FireAfterDelete(e);

Source File: x:\Projects\Umbraco\Umbraco_7.0\src\umbraco.cms\businesslogic\macro\Macro.cs Line: 246

Stack Trace:

[SqlException (0x80131904): The DELETE statement conflicted with the REFERENCE constraint "FK_cmsMacroProperty_cmsMacro_id". The conflict occurred in database "v7new", table "dbo.cmsMacroProperty", column 'macro'. The statement has been terminated.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +1789270 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +5340622 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1691 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +275 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) +1421 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +177 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +208 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +163 StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteNonQuery() in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\Data\ProfiledDbCommand.cs:266 Umbraco.Core.Persistence.<>c__DisplayClass1.b__0() +100 Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction(Func1 func) +402 Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy) +196 Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command, RetryPolicy retryPolicy) +143 Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command) +131 Umbraco.Core.Persistence.Database.Execute(String sql, Object[] args) +282 Umbraco.Core.Persistence.Repositories.PetaPocoRepositoryBase2.PersistDeletedItem(TEntity entity) +253 Umbraco.Core.Persistence.Repositories.RepositoryBase2.PersistDeletedItem(IEntity entity) +101 Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action1 transactionCompleting) +395 Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() +32 Umbraco.Core.Services.MacroService.Delete(IMacro macro, Int32 userId) +211 umbraco.cms.businesslogic.macro.Macro.Delete() in x:\Projects\Umbraco\Umbraco_7.0\src\umbraco.cms\businesslogic\macro\Macro.cs:246 umbraco.presentation.developer.packages.installedPackage.confirmUnInstall(Object sender, EventArgs e) +1466 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9614758 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.33440

Comments

Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.0

Due in version: 7.0.0

Sprint:

Story Points:

Cycle: