Problem/Motivation
The Content overview Views view filters out unpublished nodes that the given user otherwise would have access based on node access.
This issue were already reported in Drupal 7 (#1264482: Cause and work around of user not seeing own unpublished content in views) and the content moderation issue (#2971902: Unpublished content is not visible in views to users with the 'view own unpublished content' permission when used in combination with node grants) is also (partially ?) about this problem.
The root cause of the problem is \Drupal\node\Plugin\views\filter\Status that adds additional filter criteria to the query - this is the reason why ppl are suggesting disabling SQL rewriting in the content moderation thread - that filters out the result based on user permission. (See \node_views_query_substitutions())
The original code logic originates from Drupal, but I could not figure out from git history why this borned... https://git.drupalcode.org/project/views/-/commits/7.x-3.x/modules/node/...
PS.: \Drupal\node\Plugin\views\filter\Status is not the only one in Drupal core that implements the same trick, there is \Drupal\media\Plugin\views\filter\Status also.
Steps to reproduce
(See failing test in MR8156)
- Create a "content viewer" user with only the following permission: access content overview. Node admin permissions MUST NOT BE granted, see
\node_views_query_substitutions(). - Create unpublished contents with another user.
- Enabled a node access solution that would grant access to unpublished nodes to "content viewer" user.
- Check the node view page of an unpublished node with the "content viewer" user. Expected: HTTP 200
- Check the admin/content page with the "content viewer" user. Expected: unpublished nodes by other users are visible. Actual: they are missing.
.
.
.
.
Proposed resolution
Disable query altering when there is any node access module active on a site.
Remaining tasks
Title update
Review of new text
User interface changes
Before

After


API changes
None.
Data model changes
None.
Release notes snippet
Unpublished nodes are no longer hidden on Content overview page when a node access module is enabled
The Content overview page now respects the access granted in a node access module. If your site is using such a module then site administrators may see different results on the Content over page. Sites should check the behavior of the views that display nodes.
| Comment | File | Size | Author |
|---|---|---|---|
| #73 | Screenshot_20250330_215446.png | 227.68 KB | mxr576 |
Issue fork drupal-3449181
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3449181-content_overview_access_fix
changes, plain diff MR !8156
Comments
Comment #3
mxr576Comment #4
mxr576So based on failed tests after making the Status Extra filter to a NOOP, it seems what it handled and probably needs to be handled still is making sure that authenticated users can only access to their own unpublished node when
they have "view own unpublished contnet"node access grants access to them (and by default it only grants access when "view own unpublished content" is granted. This is necessary at least for BC...UPDATE Well, actually, probably... all permission based filtering that happened in runtime in
\Drupal\node\NodeAccessControlHandler::checkAccess()probably should become a query time filtering, not just for Views... #fixmeDrupal.Tests.node.Functional.Views.StatusExtraTestfailed for a good reason, it should become obsolete after this fix.Interesting. no content moderation test failed... however I expected some failures since other than the Status Extra Views plugin, nothing else run a query time filtering on results displayed on the Content overview page, does it? (Because content_moderation DOES NOT implement
hook_node_access_records()justhook_entity_access(). Am I missing something? Or maybe this part is simply not covered with tests...Comment #5
mxr576My colleague who also took part in the investigation also worth crediting here.
Comment #6
mxr576Let's do a review round on the idea...
Comment #7
mxr576Let's move this to Views module, because basically this is a Views filter plugin... (Plus "Node" has no maintainers... :screaming-cat:)
Also added "Needs subsystem maintainer review" in a hope that maintainers have a better, potentially more performant idea on how to solve this problem.
Comment #8
lendudeIf you have a node_access implementation on your site, couldn't you just remove the status filter from the View and the correct nodes would be in your View? ie. The nodes that you have access to, independent of the status? Hmm probably only if you do something with (un)published in node_access I guess
Also, this list: '***UNPUBLISHED_NIDS_ACCESS_GRANTED_BY_NODE_ACCESS***' can potentially get HUGE, at how many unpublished nodes will this fail? Depends on max_allowed_packet I guess, but it will fail at some point....
Also, with the logic that was added in #3030477: Views filter "Published status or admin user" not checking "View any unpublished content" permission and if we now add this, the responsibilities of this filter just seem to be getting too much, they certainly aren't just what the description of that filter says.
Sorry, nothing concrete to add, just general worries. Also, I see the problem, we've run into it in our projects too, just don't see a clean solution at the moment
Comment #9
mxr576Good idea, this simple one haven't came to my mind yet... but you are also right, unpublished ones would only appear if there is a node access module that grants access to them (at the query level). like view_unpublished contrib is enabled.
https://github.com/drupal/core/blob/17708a8b8146cc3476a12bda9073376eb591...
My idea in #3452449: Grant query level access to own/any unpublished nodes could be related, I do not know the historical reasons why Drupal core tried to leverage node access OOTB.
I also have this concern, I haven't found anything specific about the potential maximum length of parameters that would break this query... but again, better ideas are welcomed.
I agree, the description should be changed, the purpose changes as well.
Thanks for raising these, they were valuable inputs.
Comment #10
mxr576hmm... there is an https://github.com/drupal/core/blob/11.0.0-beta1/modules/node/src/Plugin... that does something smarter.
Comment #11
smustgrave commentedThanks for taking a look @lendude.
Trying to keep up but seems like this is still NW for the concerns expressed.
Question though
1. Does this belong in core or could be better suited for contrib? Generic question for a lot of things I see come through core so thought I'd ask
2. What about a config setting or settings variable that maybe turns it off if performance is a concern?
Comment #12
mxr576@smustgrave thanks for the review, I think your questions become irrelevant, since the fix took a complete different direction.
I realized that I did not see the bigger picture... and I realized why all related issues suggested "Disable SQL rewrite" as a "solution".
Comment #13
mxr576Comment #14
mxr576Since the solution become more simpler, probably we do not need subsystem maintainer review anymore...
Also, let's try to move this back to node module's realm...
Comment #15
smustgrave commentedNice! can issue summary be updated for new approach
Will keep an eye out.
Comment #16
mxr576I did some adjustments, do you still see any place for improvement?
I also wonder if this would need a CR or not... my current take is on NO.
Comment #17
smustgrave commentedI think it will as it is changed behavior automatically. Could be simple though with before/after screenshots maybe of the altered results?
Comment #18
mxr576I think I maybe could... but the proposed change DOES NOT alter the original query alter anymore, just disables the query alter when a node access module is installed. So in this case, would it make sense capturing queries when it is clear how the behavior was changed?
I get your point on the CR, I'll create one.
Comment #19
mxr576I guess the tag is outdated.
Comment #20
mxr576Created: https://www.drupal.org/node/3455665
Comment #21
smustgrave commentedThat CR is fantastic very nice!
Checking the MR believe the open threads were related to the previous solution which has since pivoted.
Issue summary appears to be inline with everything.
Code wise the change makes sense and I don't see any issue
https://git.drupalcode.org/issue/drupal-3449181/-/jobs/1832340 shows the test coverage.
Comment #22
mxr576\o/
Thanks for your collaboration @smustgrave!
Comment #24
quietone commentedI read the IS, and the MR (not a code review). I made 3 suggestions, 2 are wrapping and 1 changes the summary line of the test method. Those changes seems minor and do not require discussion so I have applied those suggestions.
There is a UI change here and a string change, therefore tagging. I have made screenshots and updated the issue summary. Since this is adding a sting, one that is in bold as well, I think there should be feedback from the usability team. I am going to tag for a review as well as I can't comment on the quality of the new string. Now that there are screenshots, I will ping in #ux as well.
Finally, let's have a title update that mentions node grants is involved here. Thanks
Comment #25
quietone commentedDiscussed this with xjm and confirmed that because this is change of behavior for permissions/access control that this is not eligible for a patch release. That is this is minor only and needs a release note.
Comment #26
mxr576Thanks @quietone for your work on this ticket! It makes perfect sense releasing this in 10.4.0 instead of a patch release for 10.3.x.
I added a release note snippet to the issue description, please review.
Comment #27
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #28
mxr576Comment #29
ghost of drupal pastComment #30
quietone commented@mxr576, thanks for the snippet. It was very clear, thanks! I tweaked it a bit. There is an issue for the 10.4 beta release notes. You may want to add that snippet to those sometime. I have updated the tags.
Comment #31
benjifisherUsability review
We discussed this issue at #3459320: Drupal Usability Meeting 2024-07-12. That issue has a link to a recording of the meeting. For the record, the attendees at the usability meeting were @AaronMcHale, @benjifisher, @rkoller, @shaal, @simohell, and @worldlinemine.
We did not discuss whether this issue is a good idea. It looks to me as though the site builder/administrator could achieve the same effect by removing the 'Published status or admin user' filter. If that is the case, then this issue is making a decision for the site builder, and that is usually a bad idea.
We did discuss the proposed text for the filter. For a site that does not have any modules implementing
hook_node_grants(), the additional text is not helpful and may be confusing. For a site that does have such a module, the additional text does not give a clear indication of what the options are.We recommend adding text only in the second case, and making it more specific. That is, use the same test
if (\Drupal::moduleHandler()->hasImplementations('node_grants')) {...}, and do not alter the text if the condition isFALSE. If the condition isTRUE, then do a little more work and give the administrator a list of the relevant modules. We did not discuss the exact wording, but something likeor
If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.
Comment #32
mxr576Thanks for the UX review!
They could indeed achieve the desired effect, but only if they are fully aware of how the system works behind the scenes. Many site builders and administrators might not realize that even with certain node access modules enabled, "limited editor" roles still would not see unpublished content.
Regarding the point that this issue is making a decision for the site builder, and that this is usually a bad idea, I agree. However, this decision was already made in good faith to enhance security based on previously observed misconfigurations. This issue and the associated merge request aim to roll back those changes, trusting that Drupal users are now more mature and knowledgeable about what they are doing.
Additionally, I believe the numerous recommendations on Stack Overflow and other forums to enable 'administer nodes' and/or 'bypass node access' permissions—even for limited access roles—stem from the current hidden behavior of the admin/content view, which only shows unpublished nodes when one of these permissions were granted (to non-authors).
Comment #33
mxr576I see your point and accept it as valid. However, our UX colleagues usually suggest implementing solutions where end users can still see options, even if they are not currently applicable. This approach helps users know where to find the information when it becomes relevant to them. In this context, if the help text is conditional, site builders might only realize what is happening after they start debugging the issue of "visible unpublished nodes." They won't remember that the Status filter behaves differently unless they have encountered this problem before.
Regarding the suggestion to provide a list of relevant modules if the condition is TRUE, I agree with this approach. However, I'm unsure how to achieve that at the moment without introducing a new public API. The list of modules/themes that implement a hook is protected within ModuleHandler and not accessible to external callers. #fixme
\Drupal\Core\Extension\ModuleHandler::getImplementationInfo()is protected.Comment #34
mxr576@berdir suggested a working solution for this on Slack: https://git.drupalcode.org/project/pathauto/-/commit/f465b5a7a8b1a83f2ee...
Comment #35
mxr576So this is how it looks like the requested change by UX, if everybody likes it then I guess it needs test coverage - which is not that complicated, because in a test we just need to enable
node_test(that implementshook_node_grants_alter()),node_access_test(that implementshook_node_grants()) and maybepath_test_node_grants(that also implementshook_node_grants()).Comment #36
mxr576Comment #37
anybodyComment #38
mxr576Since the final solution only disables a query alter which has a similar result that anybody could achieve by removing this views filter from a View, I do not see why performance review would be needed. By removing a query alter, the performance should be better :)
Comment #39
mxr576I hope the new issue title is better even if it uses "node access module" instead of "node grants"? #24
Comment #40
mxr576Asked the UX team on Slack if we still need the "usability" tag on this issue after #35.
Comment #41
quietone commentedYes, the Usability tag remains. The use of the tag is part of the Usability gate.
Thanks for the title update, it is much better now.
The comment above, #32 made me realize that the class docs for NodeViewsData should be updated to explain what the class will do with this change.
I left both suggestion and questions in the MR. I updated the links for that 'after' screen shots in the issue summary to the images from #35 . I did not review the change record.
Comment #42
mxr576Unrelated FunctionalJS failures, let's see if rebase from master helps...
https://git.drupalcode.org/issue/drupal-3449181/-/pipelines/277201/test_...
Comment #43
mxr576It did.
Comment #44
mxr576@quietone Thanks for your review, back to you!
I have also updated Unpublished nodes are no longer hidden on Content overview page when a node access module is enabled CR and created "Published status or admin user" Views filter becomes inactive when a node access module is enabled CR to ensure granular and precise notification about the change.
Comment #45
morvaim commentedComment #46
morvaim commentedComment #47
mxr576Comment #48
nathanhealea commentedHi I had a question and possibly some feedback for this fix.
We have ran into this issue on a site at our institution. In our situation we have a View Block that uses the the "Content: Published status or admin user" filter and we have the View Unpublished modules installed and enabled. What we have notices is after updating to Drupal 10.3.5 content editors, lost the ability the view the View Block as logged in users, however non authenticated user could see the content. We discover that removing filter and en adding it fixed the issue.
Additionally, we ran another test using the patch provided in this post. The patch did change the UI elements indicating that the filter would not have an effect, however the content did not present. It wasn't until we removed the "Content Published status or admin user" filter and re add it did the content get presented as normal.
My questions:
Comment #49
smustgrave commentedHiding patches since fixes are in MRs now. That said the MR 8156 appears to have build errors.
Comment #50
mxr576Interesting, there were no conflicts. Back to Needs review.
Thanks for your feedback @nathanhealea, I have asked my colleague to try to reproduce the issue you reported. Thanks to the test coverage in the MR I am quite confident that the solution works, but there is always a chance for unknown issues.
Comment #51
mxr576Ahh, so previously the pipeline failed due to transient errors.
Comment #52
mxr576Comment #53
morvaim commentedHi @nathanhealea,
I would like to try to reproduce what you described and I would need more context. In the first scenario from which Drupal core version did you perform the update to 10.3.5? Was the patch applied during the update? Which related permissions do content editors have on your site? Is the content which was visible for non-authenticated users but not for content editors published or unpublished? And same question for the second scenario: was the content published or unpublished which disappeared? Did the content disappear for all kind of users?
Comment #54
mxr576My gut says that this is some kind of stale cache or the lack of cache clear between the patch is being applied and site was visited. But as @morvaim said, some more context could came handy for reproducing this, for example, the source of the View block.
Currently I do not believe that the reported issue is blocking the merge of the MR.
Comment #55
mxr576There are no merge conflicts atm but this branch is behind HEAD with 100+ commits, so I am rebasing to ensure whoever reviews the latest changes can review an up to date state.
#goForTenDotFourDotZero
Comment #56
morvaim commentedLooks good to me.
Comment #57
mxr576The MR still applies.
Comment #58
larowlanthere are still some open threads in the MR, I've pinged quietone to see if the replies are sufficient for some of them to be marked resolved
Comment #59
mxr576Comment #60
mxr576Comment #61
quietone commentedI have updated credit. I am satisfied that my questions have been answered.
Comment #62
quietone commentedThis was RTBC before my questions and comments and none of the resulting changes effect the production code, so I am restoring the RTBC.
Comment #63
mxr576Removing the tag, since this has not been merged before 10.4.0 got released. :-(
Comment #64
mxr576The MR was still mergeable, but merged 11.x to keep the MR up to date.
Comment #65
longwaveAdded a suggestion to improve readability and also this will only land in 11.2 so I updated the deprecation notice.
Comment #67
mxr576Thanks @longwave for the suggestions and @prabha1997 applying them. I have also bumped versions on related CR-s.
Should be ready to be merged, right? :)
Comment #68
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #69
mxr576There was no conflict, so moving back to RTBC.
Comment #70
larowlanFunctionally I think this issue is ready to go, but I'm concerned from a security POV for existing sites that have both this filter and node access modules.
I think we should add a hook_requirements error for sites that have node_access/alter implementations and any views that use the status filter.
I.e. I think if the site has node access implementations AND we should iterate over their views AND if we find any using the status filter, we should show a requirements error, something along the lines of 'Please review these views, they use the status filter but it does not do any filtering because you have node_access modules enabled'.
Yes we have a release note snippet for it, but not everyone reads those.
Comment #71
mxr576That makes sense. If this change is introduced in a new minor version, couldn’t we instead provide an update hook to remove the unnecessary status filter from affected Views? Or would that only be feasible in a new Drupal major release? (The idea came when I checked code examples for the requirement checks and found all these config update implementations in
\Drupal\views\ViewsConfigUpdater.)If the plan is to introduce this in 10.4.x and 11.1.x (which I’d love to see happen after all these iterations), then these versions could include the requirements warning, while the subsequent minor versions could handle the removal of redundant filters via an update hook.
Comment #72
larowlanI would prefer to avoid an update hook
Comment #73
mxr576Needs review, and feedback welcomed on the wording.
("Please" was removed from the message since the screenshot is taken.)
Comment #74
morvaim commentedFound one typo, other than that LGTM.
Comment #76
larowlanCommitted this to 11.x and published the change records.
Thanks for the patience here @mxr576
Hopefully having this in 11.x means we get some contrib tests against it and they might reveal things we've not considered or otherwise.
Comment #78
mxr576Awesome! Thanks for bearing with me!
So this is not eligible anymore for backporting to 10.5?
We will see, I am only excepting contrib test failures in case they were asserted on something that they should not or not valid anymore.
Comment #80
xjmI should have been credited for the release management discussion; adding here. :)