Problem/Motivation

While the interface itself https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Access%21... has a warning , the methods don't. See https://twitter.com/_klausi_/status/1183778372410888192

Proposed resolution

Add more documentation. Mark isForbidden and isNeutral as internal, they should never be called.

Remaining tasks

User interface changes

API changes

No hard changes, it's just doxygen.

Data model changes

Release notes snippet

Comments

Charlie ChX Negyesi created an issue. See original summary.

ghost of drupal past’s picture

Status: Active » Needs review
StatusFileSize
new1.92 KB
wim leers’s picture

+++ b/core/lib/Drupal/Core/Access/AccessResultInterface.php
@@ -31,11 +34,10 @@ public function isAllowed();
+   * @internal
    */
   public function isForbidden();

This is not true. Some access control logic may choose to return early if an intermediary result already is forbidden. That is a valid optimization strategy. If the logic whose execution can be avoided is very expensive (for example involving network I/O), that also is not premature optimization.

joachim’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Access/AccessResultForbidden.php
@@ -4,6 +4,10 @@
+ * This is a kill switch — both orIf() and andIf() will result in
+ * isForbidden() if either results are isForbidden() and as such when checking
+ * for access with isAllowed() the end result will be FALSE.

'This' referred to the isForbidden() method in the paragraph that is being removed in this patch. If we're moving this paragraph to the AccessResultForbidden class, then 'this' no longer means the same thing.

Also, this sentence is too long and hard to understand.

ghost of drupal past’s picture

Status: Needs work » Needs review
StatusFileSize
new1.6 KB

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.

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.

smustgrave’s picture

Component: base system » documentation
Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

The documentation changes to AccessResultInterface in #5 makes sense to me. Not sure what more to test for that.

catch’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

This looks good. I added an extra 's' on 'return' (i.e. just because this returns FALSE) on commit.

  • catch committed fae5cc41 on 10.0.x
    Issue #3087868 by Charlie ChX Negyesi, Wim Leers, joachim, smustgrave:...

  • catch committed f812be0d on 10.1.x
    Issue #3087868 by Charlie ChX Negyesi, Wim Leers, joachim, smustgrave:...

  • catch committed 89a01aba on 9.5.x
    Issue #3087868 by Charlie ChX Negyesi, Wim Leers, joachim, smustgrave:...
catch’s picture

Status: Fixed » Closed (fixed)

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