Problem/Motivation

A batch of small fixes:

  1. NodeGrantDatabaseStorageInterface::alterQuery return value was incorrect.
  2. NodeGrantDatabaseStorage::access had an unnecessary closure .

Steps to reproduce

See above

Proposed resolution

Remove @return from ::alterQuery
Remove closure from ::access

Remaining tasks

None

User interface changes

None

Introduced terminology

None

API changes

Remove invalid return docs from NodeGrantDatabaseStorageInterface::alterQuery

Data model changes

None

Release notes snippet

None

Issue fork drupal-2402635

Command icon 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:

Comments

chx’s picture

Issue summary: View changes
StatusFileSize
new4.1 KB
xjm’s picture

  1. +++ b/core/modules/node/node.api.php
    @@ -27,7 +27,7 @@
    - * list IDs that this user is a member of.
    + * list IDs that this user is a member of. Do not use 'all' as a realm.
    

    I'd clarify why ('all' is a special reserved realm etc.).

  2. +++ b/core/modules/node/src/NodeGrantDatabaseStorage.php
    @@ -116,7 +108,7 @@ public function access(NodeInterface $node, $operation, $langcode, AccountInterf
    -    $query->addExpression('COUNT(*)');
    +    $query->addExpression('1');
    

    Eh?

  3. +++ b/core/modules/node/src/NodeGrantDatabaseStorage.php
    @@ -126,7 +118,7 @@ public function checkAll(AccountInterface $account) {
    -    return $query->execute()->fetchField();
    +    return (int) $query->execute()->fetchField();
    

    Comment explaining the typecast would be good.

  4. +++ b/core/modules/node/src/NodeGrantDatabaseStorageInterface.php
    @@ -44,9 +46,6 @@ public function checkAll(AccountInterface $account);
    -   *
    -   * @return int
    -   *   Status of the access check.
    

    Why removing this?

chx’s picture

StatusFileSize
new4.34 KB
new1.58 KB

1. Clarified.
2. Clarified.
3. Clarified.
4. Because it's false information. alterQuery has no return value. It's a copy-paste and completely bogus.

chx’s picture

StatusFileSize
new4.95 KB
new768 bytes

Even if this revision is not liked, the $grant['langcode'] should be swapped out for $grant_langcode; to make it more clear IMO.

And then we need to talk about storing node 0 grants in a followup.

xjm’s picture

Assigned: xjm » Unassigned
Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/node/node.api.php
@@ -27,7 +27,8 @@
- * list IDs that this user is a member of.
+ * list IDs that this user is a member of. 'all' is a reserved realm and can't
+ * be used.

So, hm. This is confusing. See the docs for hook_node_access_records().

xjm’s picture

Status: Reviewed & tested by the community » Needs review

Whoops. I was going to RTBC, but then had second thoughts as in #5. ;)

chx’s picture

StatusFileSize
new4.22 KB
new643 bytes

Sure, let's remove the 'all' part. It seems the special handling code in write is never called and probably $realm should be removed from the write() function header.

jhedstrom’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
ravi.khetri’s picture

Status: Needs work » Needs review
StatusFileSize
new4.93 KB

ReRolled.

Status: Needs review » Needs work

The last submitted patch, 9: 2402635_9.patch, failed testing.

Status: Needs work » Needs review

ravi.khetri queued 9: 2402635_9.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2402635_9.patch, failed testing.

Status: Needs work » Needs review

neetu morwani queued 9: 2402635_9.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2402635_9.patch, failed testing.

googletorp’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new4.94 KB
new1.32 KB

Clean up whitespace in patch from 9.

Status: Needs review » Needs work

The last submitted patch, 15: various_small_fixes_to-2402635-15.patch, failed testing.

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.

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.

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.

neclimdul’s picture

Status: Needs work » Needs review
StatusFileSize
new4.37 KB
new691 bytes

Whitespace fix and re-roll.

neclimdul’s picture

StatusFileSize
new5.25 KB
new905 bytes

Self review and update.

+++ b/core/modules/node/src/NodeGrantDatabaseStorageInterface.php
@@ -12,14 +12,16 @@
-   * Checks all grants for a given account.
+   * Checks for a "view all" grant for a given account.

This same documentation is used for

NodeAccessControlHandlerInterface::checkAllGrants()

which just proxies through to the storage interface so they should match. I think its kinda confusing that 'view all' is the op 'view' but that matches the hook_node_grants() documentation so I guess that's fine.

Came here for the weird anonymous function fix but the rest looks good. Don't think its right to RTBC myself but reviewing this everything looks right so I can't see a reason this isn't ready to go.

neclimdul’s picture

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

Bumping release for tests

The last submitted patch, 23: 2402635-23.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 24: 2402635-24.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

neclimdul’s picture

StatusFileSize
new5.25 KB
new1.45 KB

Those failures... I don't understand how book is the only thing catching the node access cache context logic. Its even worse then that too because the failures are all because my automated re-roll kept a cache context that no-longer exists. It might have broke the whole thing and we wouldn't know :( :( :(

#2946073: Node grant access check missing cacheable dependency on node is working to fix part of this but clearly we need some tests around this big complex chunk of code.

Anyways, here's a patch that restores the cache context logic.

ravi.shankar’s picture

Status: Needs work » Needs review

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

smustgrave’s picture

Category: Bug report » Task

Changing to a task as this seems more like an improvement than a bug.

smustgrave’s picture

StatusFileSize
new1.85 KB
new5.21 KB

Rerolled for 9.5.x

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new73 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

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.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Needs review

Rolled #36 into an MR with 2 omissions:

1. The node.api.php docs changes didn't apply and it was hard to figure out where they were actually meant to go (those docs have since changed quite a bit). I'm happy for someone to put them back
2. The docs changes to checkAllGrants - I may be wrong but it looks like it's checking more than "view all"?

I also added back $access_result->addCacheContexts(['user.node_grants:' . $operation]);

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

Haven't reviewed but could IS be updated please.

acbramley’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Updated

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs title update

Thanks, seems to have a valid test failure. Am tagging for title update as I've seen general titles before kicked back so trying to avoid that.

acbramley’s picture

Title: Various small fixes to node grant storage » Remove closure from NodeGrantDatabaseStorage::access and fix return type of alterQuery
Status: Needs work » Needs review
Issue tags: -Needs title update

Test failure was a random.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe all feedback has been addressed.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The 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.

acbramley’s picture

Status: Needs work » Reviewed & tested by the community

Forgot to set back to rtbc post rebase.

xjm’s picture

Saving issue credits.

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 11.x - nice to see this one solved after so many years 💪

  • larowlan committed ea6d5f02 on 11.x
    Issue #2402635 by acbramley, chx, neclimdul, smustgrave, googletorp, xjm...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.