I get the following error:
Notice: Trying to get property of non-object in user_access() (line 798 of /home/web/drupal/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 810 of /home/web/drupal/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 811 of /home/web/drupal/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 817 of /home/web/drupal/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 820 of /home/web/drupal/modules/user/user.module).
At the same time, the "People" link disappears from Admin Menu, and clearing caches doesn't help. The only thing that helps is to disable Administration Views.
Cause:
When you have 2 admin views with the same system path. I.e you have cloned the default one provided by the module in order to override/featurise it.
Workaround:
Disable one of the views. I.e disable the default view if you have cloned from it.
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | admin_views-n1780004-62.patch | 5.38 KB | damienmckenna |
| #54 | interdiff-1780004-53-54.txt | 4.98 KB | sgdev |
| #54 | admin_views-duplicate_system_path-1780004-54.patch | 5.38 KB | sgdev |
| #51 | admin_views-duplicate_system_path-1780004-51.patch | 4.02 KB | sgdev |
| #49 | admin_views-duplicate_system_path-1780004-49.patch | 1.74 KB | sgdev |
Comments
Comment #1
antiorario commentedI've gone back in time, and the last git commit that doesn't give me an error is d53d1bf from July 24.
As far as I can see, the error is caused by the changes in plugin/views_plugin_display_system.inc on July 26, but so far I haven't been able to pinpoint exactly where the problem lies.
Comment #2
standingtallSame here .. issue happened after updating the module.
Comment #3
lpalgarvio commentedand same here
getting a lot of notices on all page requests
Notice: Trying to get property of non-object em user_access() (linha 811 de /modules/user/user.module).Comment #4
damiankloip commentedWhat version of views and VBO is everyone using? Have you overridden the views?
Comment #5
afoster commentedI'm using VBO 7.x-3.0-rc1 - I have overridden the default view but just to update add a page view with a custom path.
After disabling and re-enabling I'm seeing a Broken Handler in relationships in the "system" view.
Relationships
Content: Author << Normal
Broken/missing handler << This looks like the culprit throwing the error.
Comment #6
antiorario commentedGot it. If I'm understanding this correctly, the new version changes the machine names of the admin views, which means that if the views from the old version had been overridden, now there are two sets of views with the same paths. This creates a conflict.
The problem is fixed by either disabling the new views (possibly changing access settings to "Menu system path" in the old overridden views), or by removing the old overridden views altogether.
The Broken/missing handler in #5 sounds like a problem with a VBO update.
Comment #7
damiankloip commentedThat's why I was asking in #4 if people had overridden views. This would probably break things. All of you having issues were. I guess, coming straight from the alpha release to the 1.0. So there is really no obligation to provide an upgrade path :) Revert your views and you will be fine.
Comment #8
tdurocher commentedI don't have a revert in my views list. And anyway, doesn't revert mean I would lose the extensive changes I have made? On the staging site, this problem did not occur. In both sites I am running version 7.x.3.1 of Views and rc1 of VBO so it doesn't appear that these versions of are part of the problem.
Comment #9
tdurocher commentedOops, my bad. Wrong information in my last post. On my staging site Views is on 3.5, though VBO is still in rc1. So possibly upgrading Views will solve the problem. I can't try it right now on the production site, but I wanted to quickly correct my last post.
Comment #10
afoster commented@tdurocher - I can't promise this will do the trick, but I did something similar the other day which saved me some time.
In Views find "Administration: Nodes" (Or which ever view you're using) and use Operation "Clone" . You'll now have a "normal" view completely detached from the module. Disable the view made by admin views and work on the clone.
For me it was just a matter of delete the relationship with the author, and removing busted fields (as I don't need author info). You can very likely remove the broken handler and then re-creating the author relationship and effected fields. Much less work then recreating all your customizations.
Just to note future module upgrades won't effect the clone view any more.
Comment #11
tdurocher commentedThanks afoster. This did work for my node listing view, but not for my user listing - a view I worked long and hard on. However, upgrading from views 3.1 to the latest - 3.5 - did the trick. I guess that's why only some of us were seeing this very major problem.
Comment #12
damiankloip commentedGlad you guys seem to have sorted your issues, Using a very old views release (3.1) with a new module release dependent on views is usually not a good idea. There are a few things that are only in views newer releases that this modules default views uses.
Also, if you are overriding these default views. I'm not sure we support that, especially not during upgrades etc..
Comment #13
superjerms commentedWanted to chip in, just in case someone had the same slight variation I had.
To the best of my recollection, I hadn't overridden anything, and I was using up-to-date versions of everything, but something, somewhere, created a duplicate Administration: Nodes view, called admin_content_node. So, disabled that and I was golden.
Cheers.
Comment #14
damiankloip commentedThere must have been something overridden and saved in the database, otherwise with the update that view would have disappeared :)
The name of the view has changed from admin_content_node to admin_views_node. So, the only way you could have had both is one in code and one in the database.
Comment #15
giorgio79 commentedThank you @superjems, your solution worked.
I had two views as well:
one called admin_content_node at admin/content
one called Administration : Nodes at admin/content
Disabling admin_content_node solved the problem.
Comment #16
damiankloip commented@giorgio79, you should really just delete the old admin view that you have saved in the database (admin_content_node). Alternatively you can run one the the CTools drush commands to revert all admin views in one command, which I would recommend :)
'drush cter views_view --module=admin_views'
Comment #17
giorgio79 commentedThank you damiankloip! Just deleted the admin_content_node. Also ran the drush command, but it did not remove the admin_content_node view probably because I disabled it before. Manually deleted it now.
Comment #18
Dr. Bytes commentedsuperjerms++
I found the same view "admin_content_node" in the Views listing, and I did not create it, yet, it was most definitely the cause of the error for me. Instead of disabling, I just deleted the view, and life went back to normal.
Comment #19
damiankloip commentedJust to clarify (and as I mentioned in #12) to any more people having these issues; You will only have these old views if they had previously been saved to the database before you upgraded to the new version :) So first check which views are overridden (you can do this with drush ctools commands), as when the new views come from the new release, you have a database version that is now just in the database and not overridden.
Comment #20
drupalerocant commentedJust updated from administration views to the new 7.x-1.0 and had the same issue.
Disabling the admin_content_node did the trick.
thanks so much!
Comment #21
damiankloip commentedWhy not just delete the view?
Comment #22
drupalerocant commentedI disabled it first just in case something happened. I just deleted it and everything fine.
Comment #23
gingerfrog commentedHad the same problem, just cloned the admin user list view, made a page display, and then error message started appearing as well as the people admin menu item disappeared from admin menu.
I went into my new 'cloned' view and deleted the 'system' display and now all is well.
Hope that helps
Comment #24
pubino commentedDisable and then re-enable admin_views_user.
Comment #25
NenadP commentedI have this issue too after updating to new version. But I included some custom Fields and filter criteria entries in my old admin_content_node. Not only one or two, I added several definitions. So could I delete new view and keep my old one ?
Or it is advisable to delete admin_content_node and recreate fields in new view?
Comment #26
acbramley commentedIt seems that this happens if you have any admin views overriding the same path, to fix you must disable one of them and clear cache.
EDIT: I think this is possibly still a bug though as if you debug what is actually causing the error it's passing the permission string as the $account object in user_access() which is obviously very bad.
I found it quite odd that admin_views provides defaults for all administration type pages because to export your own changes you must first clone the ones admin_views provides, then disable the defaults and export the new clone. However, the default's do help in getting a headstart
Comment #27
acbramley commentedBug exists in 1.2
Comment #28
damiankloip commentedWhere are you seeing this being passed to user_access? Our access plugin doesn't use user_access. Elsewhere in views? More details on that would be good.
Also, why is it odd to provide default views for a module that is about providing default views?
Comment #29
acbramley commented@damiankloip Your code doesn't have to call user_access for it to be called, views will call this for each entity to ensure a user can see it.
To replicate this bug form a standard install:
1) Enable admin_views
2) Clone a default view from admin views (for this example I'll use Administration: Users)
3) Save the view with the same path
4) You should now see the errors at the top of the views edit page.
5) Navigate to admin/people, you'll see more errors and an Access denied (see screenshot).
I don't know why a permission is being passed as the $account object but I assume it's an issue with having 2 admin views with the same path. Should we not check when setting the path whether a display already has this path? Page displays do this already.
The thing about the default views: The reason I mentioned it is for the exact reason I found the bug. Most people would want to alter what the module provided by default. To do this they must clone, save, and disable the old view before their new one will work. Otherwise, altering the default view will make them non exportable.
Comment #30
damiankloip commentedThanks, I'm ok with the access system. Let me be more explicit. What I mean is that this is an affect of upstream code in views, not this module.
Where do you mean page displays do this? They don't validate this on a UI level, you mean as a result of execute_hook_menu()? So this is invoked on display plugins from views_menu_alter, which does check for already existing paths. However, this checks the return value from execute_hook_menu so for normal pages this is fine, as it will only return n items array, but in admin_views we have modify the $callbacks array that is passed in by reference aswell.
I would say the best fix is possibly to add UI level validation of this?
Welcome to the CTools export system...
Comment #31
acbramley commented@damiankloip I am simply trying to fix a bug that other people may encounter, I'm not trying to prove you wrong as your responses suggest.
You are correct though! This is a bug in views itself, I remember the page display did used to validate on a UI level. That does not seem to be the case anymore and creating any display on a path that already exists causes this bug. Changing project, although there may be another issue already out there.
Comment #32
kenorb commentedBacktrace:
It seems that record in menu_router table is passing extra argument to user_access().
The following query listing all these invalid entries:
or by drush:
This should shows something like:
See the access_arguments which has 2 items instead of one.
This could be caused that I've two views which share the same path and permission. Comment #29 confirms that.
This happens even if one of the view is disabled.
Comment #33
kenorb commentedDuplicate of:
#1771140: view_menu_alter() adding to existing "access arguments" causes user_access() error
Comment #34
kerasai commentedI was receiving this using Views 7.x-3.7, with VBO and Admin Views.
Cache clear fixed it.
Comment #35
Ace Cooper commentedThis article helped me to fix the same error after enabling Admin Views:
https://swsblog.stanford.edu/blog/troubleshooting-administration-views-7...
Comment #36
danepowell commentedI think the vast majority of users are encountering this after enabling Admin Views, so I'm moving this back to the Admin Views queue to make it easier to find, even though the root cause may lie within Views.
Comment #37
joelpittetReactivating to get feedback on #36
Comment #38
damiankloip commentedThis is a won't fix for me. These problems are related to people upgrading from an alpha release I think?
Comment #39
danepowell commentedFor me at least the problem has nothing to do with an upgrade- it occurs on a fresh installation of admin_views 1.5.
#1771140: view_menu_alter() adding to existing "access arguments" causes user_access() error fixes this for me, but I don't know if it's the _best_ fix or not. From the sound of it, there may be a way to fix this in admin_views as well.
Comment #40
phponwebsites commentedGetting same issue. I've cloned admin/content view and changed path into my custom path. When i tried to access my custom path, drupal says 'Page not found'. how to solve this?
But #23 is worked for me.
Comment #41
damiankloip commentedThat is the expected behaviour. The admin views system handler does not work with custom paths, otherwise it would just be a page display :) You need to clone this as a page display. There was a recent security issue with the last release that had good reason for this.
Comment #42
acbramley commented@phponwebsites I have updated the issue description with the cause and workaround.
Comment #43
calebtr commentedI also get this on a fresh install - admin/content was inaccessible after I cloned the "Administration: content" view. Disabling the original view and clearing caches fixed it up.
A possible solution is to remove the 'clone' option in the contextual menu and provide an 'Override' option instead, which would disable the original view and clone it.
Comment #44
mbarcelo commentedThanks @calebtr I have the same problem with my custom admin views. There was a duplicate path for admin/people in my case. Solved changing the custom view to another path or disabling the standard one.
Comment #45
drupalninja99 commentedDitto with #44
Comment #46
sgdev commentedPatch for review is attached.
Comment #47
sgdev commentedSorry, code formatting typo in last patch. Give this one a try. Thanks.
Comment #48
damiankloip commentedThis currently checks all views and modifies menu router items for any view with a duplicate path, not just admin view ones.
This also looks overly complex in general to me, we could just load all views using the system display, and go from there. I'm not really sure I like the idea of altering menu data.
Comment #49
sgdev commentedNew version of the patch that limits to system displays. Regarding altering menu data, I only see one of four ways this issue can be resolved:
1) Remove the extra access arguments from menu data as is done in this patch.
2) Add validation to Views submit to block a system display from being saved when the same path already exists.
3) Modify Drupal core
user_accesstoreturn FALSEif$accountis a string.4) Modify Drupal core menu creation to not allow a second item in an "access arguments" array that is a string.
The problem is Drupal uses the menu item's access arguments
[0]and[1]foruser_access($string, $account)(where$stringis a permission). The cause of the Admin Views errors is the duplicate system paths create situations where the function being processed is "user_access('administer users', 'administer users')". This is completely wrong; the second parameter cannot be a string.Comment #50
damiankloip commentedYeah, We know what the issue is here. It's been around for a long while now. How this patch approaches it is not one that I want to commit I'm afraid. Altering menu items for what is essentially just a mis-configuration. This should therefore just be a validation error on the display path options form IMO.
Comment #51
sgdev commentedIf unwilling to accept altering menu data, you should have been more direct in #48.
To be clear, the menu alter is just to avoid displaying the
user_access()notices. It doesn't fix anything, and it isn't permanent. Once the site builder fixes paths, the menu items are no longer altered.Based on your response, I assume you consider displaying the PHP
user_access()notices acceptable?See attached. If you don't like
admin_views_page_alter, just say so. However, I think it would be misguided to not give information to sites already using admin_views.Comment #52
damiankloip commentedI don't like it. That's a worse approach as it runs on every page.
I said in #48 I didn't like the idea of altering menu data. Didn't realise you needed it to be more obvious than that...
I'm not overly interested in people that decide to configure two views to use the same path. We should add validation for this and leave it as that for now. As well as than even something notifying people in requirements would be fine. Running something on every page load to cater for more of an edge-case misconfiguration seems overkill.
Comment #53
sgdev commentedThis comment made me give some extra thought.
I don't consider this the fundamental issue. What I believe is happening in 90%+ of the cases is people are cloning a default view, never modifying the path, saving the view, and not realizing there is a conflict.
To address this, validation should be added to both the path option and view.
Comment #54
sgdev commentedOne further update. Previous version had a couple of bugs that needed to be fixed. Also made the supporting functions more modular, which allowed some code to be removed.
Comment #55
predy commentedThe patch at #54 works like a charm for me.
Comment #56
sevyx commentedThe create content at admin/content page suddenly disappeared from admin menu and refused access at admin/content direct. No new modules, nothing changed, just suddenly occurred.
So 13 to 15 had it right for me.
I had two views as well:
one called admin_content_node at admin/content
one called Administration : Nodes at admin/content
Deleted admin_content_node view and content reappeared in the admin menu and all working fine. Solved for me, thanks.
Comment #57
chris matthews commentedThe 2 year old patch in #54 to admin_views.module and views_plugin_display_system.inc still applied cleanly to the latest 7.x-1.x-dev, but after reading through this thread I'm not sure where to go with this issue.
Comment #58
sgdev commented@Chris2, my opinion is this is a nasty issue that can leave developers scratching their heads as to why this would be happening.
I believe patch #54 is reasonable and fair, and addresses the previous comments.
Comment #59
chris matthews commentedThanks ron_s, I read through the issue thread a 2nd time and I agree. Is anyone else able to do another review/test before changing to RTBC?
Comment #60
jaesperanza commented- Cloned Administration: Users /admin/people
- Produces errors: Notice: Trying to get property of non-object in user_access() on multiple lines .../modules/user/user.module)
- Page /admin/people becomes inaccessible (Access denied)
- Installed/Used dev version - admin_views-7.x-1.x-dev
- Ran db updates, flushed cache, etc.
- refreshed /admin/people - still Access denied
- tested disabling the cloned view, admin/people is ok
Comment #61
chris matthews commentedComment #62
damienmckennaRerolled after #2411193: Move 'system' display plugin to a submodule was committed.
Comment #64
damienmckennaCommitted. Thanks everyone.