3

我有一个托管在 azure 上的果园网站连接到 sql azure 数据库,我不断收到 No row with the given identifier exists[Orchard.Roles.Models.PermissionRecord#33] 这是堆栈跟踪。

[ObjectNotFoundException: No row with the given identifier exists[Orchard.Roles.Models.PermissionRecord#33]]
NHibernate.Impl.DefaultEntityNotFoundDelegate.HandleEntityNotFound(String entityName, Object id) +56
NHibernate.Proxy.AbstractLazyInitializer.CheckTargetState() +48
NHibernate.Proxy.AbstractLazyInitializer.Initialize() +87
NHibernate.Proxy.DefaultLazyInitializer.Intercept(InvocationInfo info) +85
PermissionRecordProxy.get_Name() +192
Orchard.Roles.Services.RoleService.GetPermissionsForRole(Int32 id) +128
Orchard.Roles.Services.RoleService.GetPermissionsForRoleByNameInner(String name) +37
Orchard.Roles.Services.<>c__DisplayClasse.<GetPermissionsForRoleByName>b__d(AcquireContext`1 ctx) +26
Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:57
Orchard.Caching.<>c__DisplayClass2.<Get>b__0(TKey k) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:19
System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory) +125
Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\Cache.cs:17
Orchard.Caching.DefaultCacheManager.Get(TKey key, Func`2 acquire) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Caching\DefaultCacheManager.cs:33
Orchard.Roles.Services.RoleService.GetPermissionsForRoleByName(String name) +100
Orchard.Roles.Services.RolesBasedAuthorizationService.TryCheckAccess(Permission permission, IUser user, IContent content) +595
Orchard.Security.Authorizer.Authorize(Permission permission, IContent content, LocalizedString message) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\Authorizer.cs:72
Orchard.Security.Authorizer.Authorize(Permission permission) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\Authorizer.cs:60
Orchard.Security.SecurityFilter.OnAuthorization(AuthorizationContext filterContext) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Security\SecurityFilter.cs:24
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +97
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +311
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +23
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
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() +55
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in c:\Users\sebros\My Projects\Orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:162
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

我在 PermissionRecord 表中查看了数据库,数据库中根本没有 ID #33。当我将果园网站下载到 webmatrix 以对其进行本地开发时,该网站根本没有给我任何错误并且工作正常,它也正确连接到 sql azure 数据库。所以我有点困惑为什么这在 azure 上不起作用,因为它在本地工作,并且它应该使用与 azure 网站上相同的文件,因为我直接从 azure 网站下载了文件。有人有想法么?

4

1 回答 1

3

这已经很晚了,但我今天早上在果园 1.6 上遇到了类似的情况。不知道它是如何发生的!我希望这对遇到同样问题的其他人有所帮助。

(我想我在很久以前启用模块权限后已经更改了模块权限,并且在将损坏的角色分配给用户之前没有注意到任何问题)

我使用这段 sql 来查找违规记录:

SELECT        TOP (1000) MyPrefix_Orchard_Roles_RolesPermissionsRecord.Id, MyPrefix_Orchard_Roles_RolesPermissionsRecord.Role_id, 
                     MyPrefix_Orchard_Roles_RolesPermissionsRecord.Permission_id, MyPrefix_Orchard_Roles_RolesPermissionsRecord.RoleRecord_Id, 
                     MyPrefix_Orchard_Roles_RoleRecord.Name AS RoleName, MyPrefix_Orchard_Roles_PermissionRecord.Name AS PermissionName, 
                     MyPrefix_Orchard_Roles_PermissionRecord.FeatureName AS PermissionFeatureName, 
                     MyPrefix_Orchard_Roles_PermissionRecord.Description AS PermissionDescription
FROM            MyPrefix_Orchard_Roles_RolesPermissionsRecord LEFT OUTER JOIN
                         MyPrefix_Orchard_Roles_PermissionRecord ON 
                         MyPrefix_Orchard_Roles_RolesPermissionsRecord.Permission_id = MyPrefix_Orchard_Roles_PermissionRecord.Id LEFT OUTER JOIN
                         MyPrefix_Orchard_Roles_RoleRecord ON MyPrefix_Orchard_Roles_RolesPermissionsRecord.Role_id = MyPrefix_Orchard_Roles_RoleRecord.Id
WHERE        (MyPrefix_Orchard_Roles_RolesPermissionsRecord.Role_id = 1) -- broken administrator role

发现有两条记录缺少 Permission 记录。一个将 RoleRecord_Id 设置为 NULL,另一个设置为 1 - 管理员。因此,当使用管理员加载权限时,查找权限记录将失败。这在一定程度上帮助了日志记录。

admin 中的几个角色部分似乎仍然存在问题:“Admin/Roles”,所以我运行了上面的 sql 脚本来查找来自不同角色的更多违规行。

我认为随机行不会引起任何问题,其他一切似乎都可以再次按预期工作。

谢谢,马特

于 2013-03-15T12:07:18.663 回答