Problem/Motivation

API page: http://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/...

"Note that the system makes no distinction between published and unpublished nodes."

I think that if "the system" here is referring only to the grants node_access table system, then yes, this is true. However, in the normal way of displaying a page, hook_node_access (and hook_node_grants after it) is only called for published nodes. Well, at least according to flowchart on p160 of "Pro Drupal 7 Development / Tomlinson & VanDyk".

Steps to reproduce

Proposed resolution

Remaining tasks

  • The new second paragraph 'the table' is referred to without defining what table is being used.
  • "realms" is kind of confusing here. It should have a definition

Review

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Title: Improve clarity around effect of published status of nodes. » Improve hook_node_grants() docs around effect of published status of nodes.
Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7
jhodgdon’s picture

Issue tags: +Novice

The code of http://api.drupal.org/api/drupal/modules%21node%21node.module/function/n... also shows the process, and how it relates to $node->status. This only applies to single-node checks though, not listings, and it is also true that hook_node_grants() doesn't distinguish between published and unpublished. So probably the hook_node_grants() docs just need to clarify that one sentence noted in the original issue report here. Probably a good Novice project...

lirantal’s picture

Status: Active » Needs review

To me the docs on hook_node_grants() are pretty clear but please review the following revised paragraph and see if it makes better sense and clarity for updating the docs:

A node access module may implement as many realms as necessary to properly define the access privileges for the nodes. Note that in cases where single-node checks are performed there is a private case of enabling the user to view his own unpublished node if the permission 'view own unpublished content' has been set for that user, in which case node access checks will stop there and hook_node_grants() will not be called. Otherwise, the node access system makes no distinction between published and unpublished nodes. It is the module's responsibility to provide appropriate realms to limit access to unpublished content.

How's that?

lirantal’s picture

Assigned: Unassigned » lirantal
jhodgdon’s picture

Status: Needs review » Needs work

That looks pretty good, except I'm not sure what a "private case" means, and the second sentence runs on for quite a while.

But maybe the right thing to do would be to link to the page that completely describes the node access process instead of partially duplicating what that page says? Which would be:
http://api.drupal.org/api/drupal/modules!node!node.module/group/node_acc...
And perhaps that page needs some additional text about the case described here?

mgifford’s picture

Assigned: lirantal » Unassigned
Issue summary: View changes
finnydobson’s picture

Status: Needs work » Needs review
Issue tags: +CatalystAcademy

Hello, I have attempted to revise the paragraph on node access rights. Please review the paragraph to see if it is explained clearly.

A node access module may implement as many realms as necessary to properly define the access privileges for the nodes. The distinction between published and unpublished nodes is clarified by node_access. Please see this link for more detailed information on the process of determining access rights for a node. https://api.drupal.org/api/drupal/modules!node!node.module/group/node_ac... It is the module's responsibility to provide appropriate realms to limit access to unpublished content.

jhodgdon’s picture

Status: Needs review » Needs work

What does "node_access" mean in this sentence:
The distinction between published and unpublished nodes is clarified by node_access.
I'm confused.

Also as a note, in documentation to make a link to a topic, use something like

See @link node_access the Node Access topic @endlink for more information.

This would be easier to check in the form of a patch.

finnydobson’s picture

Thank you for your review. This is my second attempt at the paragraph. I removed node_access from my previous attempt.

A node access module may implement as many realms as necessary to properly define the access privileges for the nodes. Note that in cases where single-node checks are performed, there is an option of enabling the user to view his own unpublished node. See @link node_access the Node Access topic @endlink for more information. The node access system makes no distinction between published and unpublished nodes. It is the module's responsibility to provide appropriate realms to limit access to unpublished content.

And as per your comment #5 I added additional text about the case described above.

If all modules ignore the access request, then the node_access table is used to determine access. All node access modules are queried using hook_node_grants() to assemble a list of "grant IDs" for the user. This list is compared against the table. If any row contains the node ID in question (or 0, which stands for "all nodes"), one of the grant IDs returned, and a value of TRUE for the operation in question, then access is granted. Note that this table is a list of grants; any matching row is sufficient to grant access to the node. In cases where users are able to view their own unpublished node, the permission 'view own unpublished content' has been set for that user and node access checks will stop there and hook_node_grants() will not be called.

jhodgdon’s picture

Please make a patch.

ottlik’s picture

Here's the patch. Just copied from finnydobson and unsplit an infinitive.

wiifm’s picture

Status: Needs work » Needs review
FileSize
2.12 KB

Thanks @ottlik, I have made some slight changes:

  • wrapped the lines so none go over 80 characters
  • removed trailing whitespace

All text is the same.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks for the patches! I think this needs some work:

a)

 ... Note that in cases where
+ * single-node checks are performed, there is an option of enabling the user to
+ * view his own unpublished node.

This sentence needs some attention. We don't normally say that we "enable the user to" do things, and where is this option anyway? Also please do not use "his" or other gender-specific language in documentation.

b)

See @link node_access the Node Access topic
+ * @endlink for more information.

@link ... @endlink all needs to be on one line.

c) Generally... I am not finding this new content very easy to follow, in the context of the rest of the documentation that is already there. It seems to wander between the single-node-access check and the grant system. It needs to be more systematic.

snehi’s picture

Status: Needs work » Needs review
FileSize
2.11 KB
1.01 KB

Assembled the input from @jhodgdon and merged with patch.

jhodgdon’s picture

Status: Needs review » Needs work
Issue tags: -Novice

Thanks for reviving this issue! I think this still needs some work though... and this is probably not a novice issue really!

  1. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * A node access module may implement as many realms as necessary to define the
    + * access privileges for the nodes properly. In cases where single-node checks ¶
    + * are performed, there is an option to the user to view their own unpublished nodes.
    + * See @link node_access and @endlink the Node Access topics for more information.
    + * The node access system makes no distinction between published and unpublished ¶
    + * nodes. It is the module's responsibility to provide appropriate realms to limit ¶
    + * access to unpublished content.
    + *
    

    This paragraph has several lines that run over 80 characters, and several that end with an extra space.

    There is also some awkward wording in the sentence about single-node checks, and again it shouldn't refer to "an option to the user". This is programmer documentation, not user documentation, so talk about what a programmer can do in a module and how to do it, not what a user can do in the UI.

    The See sentence also needs some attention. You might need to look up how to do @link:
    https://www.drupal.org/node/1354#link

  2. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * access to the node. In cases where users are able to view their own
    + * unpublished node, the permission 'view own unpublished content' has been set
    + * for that user and node access checks will stop there and hook_node_grants()
    + * will not be called.
    

    Too many "and" in this sentence.

    Also, ... this is unclear. The first part of this paragraph says that the node_access table and hook_node_grants() will be called. I think this is a bypass of that whole process, but that is not made clear by this sentence. Perhaps it belongs in its own paragraph, and perhaps it belongs before this paragraph about node_access table and hook_node_grants()?

snehi’s picture

Status: Needs work » Needs review
FileSize
2.07 KB
1.13 KB

I tried to give my better in this patch.

jhodgdon’s picture

Status: Needs review » Needs work

Sorry, but this is still not OK. The @link formatting is still wrong, and not everything pointed out in #15 is fixed. All of the wording in there about users viewing their own unpublished content is still very very wrong and/or confusing.

Shreya Shetty’s picture

Assigned: Unassigned » Shreya Shetty
Shreya Shetty’s picture

Assigned: Shreya Shetty » Unassigned
Status: Needs work » Needs review
FileSize
2.11 KB
1.32 KB

I have made some improvements

jhodgdon’s picture

Status: Needs review » Needs work

Thanks for the new patch but this is still missing the point. And it still has similar problems to before....

  1. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * are performed, there is an option to the user to view their own unpublished nodes.
    

    This line goes over 80 characters.

  2. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * See also @link node_access, Node Access topics for more information. @endlink ¶
    

    This line has an extra space at the end.

  3. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * set for that user and node access checks will stop there and hook_node_grants()
    

    This line goes over 80 characters.

  1. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * access privileges for the nodes properly. In cases where single-node checks
    + * are performed, there is an option to the user to view their own unpublished nodes.
    

    This sentence about single-node checks still doesn't fit with this paragraph and I am not sure what it means.

    Either fix it so it is right and move to its own paragraph, or (preferably) remove it.

    I really don't know where this came from or why it was added.

  2. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * See also @link node_access, Node Access topics for more information. @endlink ¶
    

    This @link is still wrong. Please read the documentation about how to do @link that I referenced in previous reviews.

    Also it is only 1 topic, not "topics".

  3. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,25 @@
    + * If all modules ignore the access request, then the node_access table is used
    

    This is a paragraph copied out of context from the node access topic. It makes no sense here.

anil.gangwal’s picture

Assigned: Unassigned » anil.gangwal
anil.gangwal’s picture

Status: Needs work » Needs review
FileSize
1.88 KB

I have made the changes. Please review my patch.

anil.gangwal’s picture

Please ignore the previous on and review this patch.

jhodgdon’s picture

Status: Needs review » Needs work

Most of what I said in the previous several reviews has still not been addressed. When a patch is made that addresses *all* of the problems, please attach it to this issue and set it to Needs review. If you cannot address all the problems, ether get help from the Core Mentoring group, post a question to the issue, or find another issue to work with. Making a patch that only addresses a small part of the problems that were identified is not helpful.

Also when you make a new patch, make an interdiff file.

Thanks!

anil.gangwal’s picture

Assigned: anil.gangwal » Unassigned
snehi’s picture

Assigned: Unassigned » snehi
snehi’s picture

  1. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,22 @@
    + * access system makes no distinction between published and unpublished nodes. ¶
    

    Blank Spaces. Please configure your IDE for not doing this

  2. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,22 @@
    + * It is the module's responsibility to provide appropriate realms to limit ¶
    

    Blank Spaces. Please configure your IDE for not doing this

  3. +++ b/core/modules/node/node.api.php
    @@ -29,11 +29,22 @@
    + * All node access modules are queried using hook_node_grants() to assemble a ¶
    + * list of "grant IDs" for the user. This list is compared against the table.
    + * If any row contains the node ID in question (or 0, which stands for ¶
    ...
    + * of grants; any matching row is sufficient to grant access to the node. ¶
    + * In cases where users are able to view their own unpublished node, the ¶
    

    Blank Spaces. Please configure your IDE for not doing this

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Parashram’s picture

Assigned: snehi » Parashram
Dinesh18’s picture

Here is an updated patch which fixed the white space issues.

Dinesh18’s picture

Status: Needs work » Needs review

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Parashram’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.4.x-dev » 9.5.x-dev
Assigned: Parashram » Unassigned
Issue summary: View changes
Status: Needs review » Needs work

Discussed in a documentation triage meeting with myself and ambermatz. Nether of us are familiar with the node grant system but we do like the additional documentation to explain the system. We also noticed a few things

The new second paragraph 'the table' is referred to without defining what table is being used.
"realms" is kind of confusing here. It should have a definition.
Needs a review from someone familiar with node grants.
Can be unassigned since it hasn't been worked on it a few years.

I have updated the IS.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Nikhil_110’s picture

Attached patch against Drupal 10.1.x

Nikhil_110’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

#43 was not addressed.

Starting March 2023, simple rerolls, rebases, or merges will no longer receive issue credit. Only rerolls that address a merge conflict will be credited, and the merge conflict that was resolved must be documented in the text of an issue comment.

Example
error: patch failed: core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module:77
error: core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module: patch does not apply

To receive credit for contributing to this issue, assist with other outstanding tasks or unaddressed feedback.
See the issue credit guidelines for more information.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.