While working on #2592293: Test access to scheduled node views, I noticed that the "view scheduled content" permission declared by Scheduler is not used anywhere. It seems this was removed when converting the list of scheduled items to views in #2423449: Convert the overview of scheduled nodes into a view, commit 382b793
The scheduled content lists both on the user page (tab) and the global content page. Both require (just) the 'access content overview' permission.
According to the now removed access check:
- // All Scheduler users can see their own scheduled content via their user
- // page. In addition, if they have 'view scheduled content' permission they
- // will be able to see all scheduled content by all authors.
So either we need to update access to the global scheduled content list, or we need to get rid of the unused permission.
Patch attached removes the unused permission.
Comments
Comment #2
mr.baileysComment #3
jonathan1055 commentedThanks for noticing this, and doing the investigation. I was not directly involved in the conversion to D8 at that time, and although I did post once on that issue, I was not yet using D8 or reviewing the code properly, but I am sorry this fault got through.
I think, rather than remove the permission, we should update the access required for the global list. It may be important for some roles not to see the scheduled content even if they do have 'access content overview'. There may be problems with showing unpublished content and the extra scheduler permission gives admins the further granularity required.
Comment #4
mr.baileysInitial patch to restore original access control (with basic test coverage) attached.
One remark: for the scheduled content overview, the view uses the "extra status" filter, which means if you access the scheduled content overview, you will see:
a) your own unscheduled content, provided you have 'view own unpublished content' permission.
b) view other unscheduled content, provided you have the 'bypass node access' permission.
The same issue occurs when user B, with "view scheduled content list', accesses user A's scheduled content list. While he does have access to the page itself, user A's scheduled content (if unpublished) will only show up if user B also has "bypass node access".
This seems counterintuitive to the "view scheduled content list"-permission, which states "Allows users to see all content which is scheduled."
I haven't yet checked how these lists behave in Drupal 7. We might want to remove the "extra status" filtering from view's configuration?
Comment #5
jonathan1055 commentedThanks for working on this.
Yes, I agree. We are providing only the 'list' of scheduled nodes (which may contain both published and unpublished content), which is what our permission is intended for. Whether or not the user can click the node and read the unpublished content should be controlled by other permissions, and in turn those other permissions should not impact the ability to see the scheduled list. We might want to improve the permission description to make this more clear.
Thank you for the tests, too. I will do some manual testing and also check the D7 behaviour.
Comment #6
jonathan1055 commentedI've done manual testing on 8.x, and also checked the 7.x behavior. I have used the following terminology to refer to user roles, and this is the same in both versions:
Notes as numbered [ ] above:
So the patch fixes the five wrong access results, but unfortunately the one which was correct is now wrong. This is because, in ScheduledListAccess the derivation has been copied from 7.x scheduler_list_access_callback. However, in 7.x the parameter $uid is NULL when viewing the full page. This is where the new function gives True. We need to make the distinction in what path is being tested.
I have not yet studied the simpletests. Great work - thank you. I will try to find where exactly the incorrect assertion is letting this pass.
Comment #7
jonathan1055 commentedThis patch is the same as #4 except with the modified tests, as explaied in #2592293-5: Test access to scheduled node views. There are 13 failed assertions using the committed codebase. I am expecting the changes by mr.baileys in #4 to fix 10 of these failures.
Comment #9
jonathan1055 commentedSame code changes as #4 but with finalised expanded tests as per #2592293-9: Test access to scheduled node views. There will be a few failed assertions as before.
Comment #11
jonathan1055 commentedAs expected, 116 passes and 4 fails.
This is due to giving a user who only has 'schedule publishing of nodes' too much access in ScheduledListAccess. The value of
\Drupal::currentUser()->id() == $account->id()is always true. To check if the user is browsing their own page we need\Drupal::routeMatch()->getRawParameter('user') == $account->id()This is where the Manager cannot see the Users unpublished content. As discussed before, this is fixed by removing the 'extra status' filter "published or admin"
This is caused by the same problem, and solved by the same fix as (1) above
Same as (3) - removing the 'extra status' fixes this
The view code is much shorter because the fields in the overridden display (user tab) were identical to the default, so reverting to default removed hundreds of lines which were not needed :-)
This patch should be fully green with 120 passes.
Comment #13
jonathan1055 commentedThanks @mr.baileys for starting this off. Committed the code here, and the tests on #2592293-10: Test access to scheduled node views
In testing the changed view I had trouble getting the changed config .yml file to be loaded. I was using Config Update Manager module and had to fix #2767635: Scheduled content view has wrong id. Now Config Update Manager is working well and it is easy to export/import/revert views.
I have created #2771375: Use dependency injection for routeMatch() in ScheduledListAccess as a separate issue, so marking this one as fixed.