devbridge / BetterCMS

A publishing focused and developer friendly .NET Open Source CMS.
GNU Lesser General Public License v3.0
375 stars 151 forks source link

Create/Edit page: UX_Cms_Pages_PageUrlHash violation can be received #1497

Open daivabrazukaite opened 8 years ago

daivabrazukaite commented 8 years ago

Currently in staging db there are ~100 records in bcms_root.pages table that contains isDeleted = 1 but null in deletedOn and deletedBy (these are old records, so maybe some bug existed there before). If user tries to save page with same url like for such a record, during Save Sorry. Internal server error occured. Please retry later or contact administrator. This is minor issue as actually currently seems there is no way using UI to get situation then deletedOn and deletedBy are not filled, but i think it would be worth to handle this error in more proper way example of error from logs: 2016-01-29 11:06:04.3885 Failed to execute command SavePagePropertiesCommand. Request data: Id: 78ed7b02-eb01-4d0b-a7d0-a59c009ded6c, Version: 3, Name: test page 0129 1. could not update: [BetterCms.Module.Pages.Models.PageProperties#78ed7b02-eb01-4d0b-a7d0-a59c009ded6c][SQL: UPDATE bcms_root.Pages SET Version = ?, IsDeleted = ?, CreatedOn = ?, ModifiedOn = ?, DeletedOn = ?, CreatedByUser = ?, ModifiedByUser = ?, DeletedByUser = ?, PageUrl = ?, PageUrlHash = ?, Title = ?, Status = ?, PublishedOn = ?, MetaTitle = ?, MetaKeywords = ?, MetaDescription = ?, IsMasterPage = ?, LanguageGroupIdentifier = ?, ForceAccessProtocol = ?, LayoutId = ?, MasterPageId = ?, LanguageId = ? WHERE Id = ? AND Version = ?] NHibernate.Exceptions.GenericADOException: could not update: [BetterCms.Module.Pages.Models.PageProperties#78ed7b02-eb01-4d0b-a7d0-a59c009ded6c][SQL: UPDATE bcms_root.Pages SET Version = ?, IsDeleted = ?, CreatedOn = ?, ModifiedOn = ?, DeletedOn = ?, CreatedByUser = ?, ModifiedByUser = ?, DeletedByUser = ?, PageUrl = ?, PageUrlHash = ?, Title = ?, Status = ?, PublishedOn = ?, MetaTitle = ?, MetaKeywords = ?, MetaDescription = ?, IsMasterPage = ?, LanguageGroupIdentifier = ?, ForceAccessProtocol = ?, LayoutId = ?, MasterPageId = ?, LanguageId = ? WHERE Id = ? AND Version = ?] ---> System.Data.SqlClient.SqlException: Violation of UNIQUE KEY constraint 'UX_Cms_Pages_PageUrlHash'. Cannot insert duplicate key in object 'bcms_root.Pages'. The duplicate key value is (b5fccfe1cdf8598f73da5db5c2f89bd9, ). The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd) at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) --- End of inner exception stack trace --- at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session) at NHibernate.Action.EntityUpdateAction.Execute() at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) at NHibernate.Engine.ActionQueue.ExecuteActions() at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) at NHibernate.Impl.SessionImpl.Flush() at NHibernate.Transaction.AdoTransaction.Commit() at BetterModules.Core.DataAccess.DataContext.DefaultUnitOfWork.Commit() at BetterCms.Module.Pages.Command.Page.SavePageProperties.SavePagePropertiesCommand.Execute(EditPagePropertiesViewModel request) at BetterCms.Module.Root.Mvc.CommandHandler.ExecuteCommand[TRequest,TResponse](ICommand2 command, TRequest request) Violation of UNIQUE KEY constraint 'UX_Cms_Pages_PageUrlHash'. Cannot insert duplicate key in object 'bcms_root.Pages'. The duplicate key value is (b5fccfe1cdf8598f73da5db5c2f89bd9, <NULL>). The statement has been terminated. System.Data.SqlClient.SqlException (0x80131904): Violation of UNIQUE KEY constraint 'UX_Cms_Pages_PageUrlHash'. Cannot insert duplicate key in object 'bcms_root.Pages'. The duplicate key value is (b5fccfe1cdf8598f73da5db5c2f89bd9, <NULL>). The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd) at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) ClientConnectionId:77bc71fa-50cc-4b52-9198-ab54c962e6ca Error Number:2627,State:1,Class:14