Currently, Views implements a pass-through check of user_access('access all views') at the main menu access callback level. This can be troublesome for a large class of access plugin implementations that may restrict access not as an access-check per se, but to control visibility of menu items for a variety of reasons (e.g. displaying a tab only for certain node types).
This patch moves this access check into the domain of each plugin, allowing a plugin to alternatively omit the 'access all views' permission as a positive condition for access. This is also more consistent with the behavior or views_block() and just a raw $view->access() check.
Patched against DRUPAL-6--2, also works with DRUPAL-6--3.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 673852_views_check_perm_callback.patch | 3.85 KB | yhahn |
| #5 | views_check_perm_callback.patch | 3.16 KB | dawehner |
| views_check_perm_callback.patch | 3.84 KB | yhahn |
Comments
Comment #1
dawehnerWhy not use isset here? isset is always faster.
Its used also for user_access of core.
Powered by Dreditor.
Comment #2
yhahn commentedNo good reason -- I did not know isset is faster. Seems like a fine change to make.
Comment #3
dawehnerIn contrast to is_null is isset a part of the language php and not a function. Thats the same case with empty.
See below
What about reversing the checks. Then php does not execute array_intersect if its not needed.
Powered by Dreditor.
I will have time tomorrow to test the patch and write simpletests for it.
Comment #4
yhahn commentedI think reversing the checks is fine and your explanation makes sense.
Comment #5
dawehnerSo here is a new version.
Comment #6
yhahn commentedWorks as expected. Thank you for the change.
Comment #7
yhahn commentedThis updated patch fixes a bad ternary. Fix by tomhung.
Comment #8
dawehnerWhich one?
Comment #9
yhahn commentedI wrote it, don't worry your conscience can be guilt free : )
In
views_check_roles():Evil patch:
Good patch:
Comment #10
dawehnerHehe i thougth this could be my problem.
The difference make sense, but a simpletest would be cool :)
The rest looks fine. I tested functionality before manually
Comment #11
yhahn commentedYeah... views is a bit too big and large to continue flying without tests right? : )
Comment #12
dawehnerHehe, there are some tests already written, but it tests perhaps 5% of views :(
So i try to make tests for every new patch, because there it is easy to know what to test. But this could be done later.
Comment #13
merlinofchaos commentedThis makes me truly loathe Drupal's behavior with UID 1.
Committed to all branches.