Problem/Motivation

#2991207: Drupal core should inform the user of the security coverage for the site's installed minor version including final 8.x LTS releases added a new ProjectSecurityData class, with a method called getAdditionalSecurityCoveredMinors(). The function is somewhat confusing, and the doc block says:

/**
  * Gets the number of additional minor security covered releases.
  *
  * @param string $security_covered_version
  *   The version until which the existing version receives security coverage.
  *
  * @return int|null
  *   The number of additional minor releases that receive security coverage,
  *   or NULL if this cannot be determined.
  */

This is rather opaque, but we agreed to commit #2991207 (to 8.9.x) as is because it is a critical issue.

The docs for getSecurityCoverageUntilVersion() could also benefit from some examples to help clarify.

Finally, there are a few formatting bugs from @todo comments that were committed with the parent issue, and a few additional @todo comments that could be added to track future work.

Proposed resolution

Flesh out these comments in more detail to explain what's really going on, inlcuding specific examples to clarify the behavior.

Remaining tasks

  1. Commit parent issue.
  2. Update docs.
  3. Review.
  4. RTBC.
  5. Commit.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Comments

dww created an issue. See original summary.

dww’s picture

dww’s picture

Note: I added a version of this on the parent issue, too:
#2991207-232: Drupal core should inform the user of the security coverage for the site's installed minor version including final 8.x LTS releases
If that becomes RTBC and committed instead of #2991207-229, we can close this (and reduce the number of commits that have to be cherry picked in the right order to get the parent feature into All The Branches(tm).

Cheers,
-Derek

dww’s picture

Issue summary: View changes
benjifisher’s picture

Issue summary: View changes
Status: Postponed » Active

The parent issue has been fixed on the 8.9.x and 9.0.x branches, so we can un-postpone this issue.

greggles’s picture

Status: Active » Needs review

And there's a patch, so I guess it needs review.

dww’s picture

Great, thanks for status updates.

This is 100% code comments, so it seems wasteful to have the bot churn on it until we're closer to RTBC. Therefore, I'm not going to queue #2 for testing (yet). ;)

Thanks,
-Derek

benjifisher’s picture

Status: Needs review » Needs work

Thanks for taking the trouble to improve these comments!

The one useful thing the testbot would tell us about this patch is whether it applies cleanly. It does.

The changes are generally an improvement, but I suggest a few changes:

  1. @@ -165,7 +169,31 @@ private function getSecurityCoverageUntilVersion() {
    ...
    +   * - The target minor release where security coverage for the current release
    +   *   should expire. This target release is determined by
    +   *   static::getSecurityCoverageUntilVersion().
        

    I do not feel strongly about it, but I think you can leave off the static::, especially since there is an @see below. (See next comment.)

  2. @@ -173,6 +201,8 @@ private function getSecurityCoverageUntilVersion() {
    ...
    +   * @see static::getSecurityCoverageUntilVersion()
        

    I find some existing examples of @see references like this, so maybe this is a new (to me) standard. But the coding standards show fully qualified class names, starting with \Drupal, not static::. Looking at the documentation pages that get generated, such as MenuTreeStorage::loadTreeData, I see that the links are generated correctly, but the link text includes static::, which is less helpful.

  3. @@ -181,17 +211,16 @@ private function getAdditionalSecurityCoveredMinors($security_covered_version) {
    ...
    -        // Therefore if we have found an official, published release with the
    -        // same major version as $security_covered_version then this release
    +        // Therefore, if we have found a published official release with the
    +        // same major version as $security_covered_version, then this release
        

    I agree with adding a comma before "then". Also after "Therefore", although I am less sure of myself there. I disagree with removing the comma between the two adjectives "official" and "published".

    Now that I am looking closely at the choice of words, I am not sure that I like "official" anywhere in this documentation. Is it redundant? Does it add anything? (Are my questions redundant?)

  4. @@ -181,17 +211,16 @@ private function getAdditionalSecurityCoveredMinors($security_covered_version) {
    ...
    -    // If $latest_minor is set, we know that $latest_minor and
    -    // $security_covered_version_minor have the same major version. Therefore we
    -    // can simply subtract to determine the number of additional minor security
    -    // covered releases.
    +    // If $latest_minor is set, we know that $security_covered_version_minor and
    +    // $latest_minor have the same major version. Therefore, we can subtract to
    +    // determine the number of additional minor security covered releases.
        

    This is an improvement, but I would make the same replacement that you made in the one-line description: "releases with security coverage" instead of "security covered releases".

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new4.49 KB
new2.3 KB

@benjifisher re: #8. Thanks for the review!

1. Removed.

2. Weird. Seems annoying to fully qualify the class name when referring to another method on the same class. I was assuming that #2158497: [policy, no patch] Use "$this" and "static" in documentation for @return types allowed this, but looking at the actual docs, you're right that @see expects a fully qualified class + method. I just think it's unfortunate. ;) I'd rather have kept static::, but I changed it to be officially compliant. /shrug

3. Restored the comma.

Re: "official" In all these docs (and the rest of update.module docs), "official release" means a release without "extra" (no alpha, beta, rc, etc). Saying "Therefore, if we have found a published release without extra with the same major version..." seems weird. So we tend to say "official release". /shrug

4. Fixed.

Cheers,
-Derek

p.s. Since this is now hopefully RTBC, letting the bot show it applies cleanly. ;)

benjifisher’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
  1. Thanks
  2. I second the /shrug response. Thanks for following the written standards.
  3. Thanks for clarifying.
  4. Thanks.

Yes, #2158497: [policy, no patch] Use "$this" and "static" in documentation for @return types is limited to @return comments. (I noticed that policy in the docs, but had not previously seen the issue.) Maybe we should have a follow-up for @see comments, especially since the links are generated correctly and there are already some examples in core. I searched for @see on that issue: it was discussed and declared out of scope, but there was some support for including it.

The additional comments are a good step forward after #2991207: Drupal core should inform the user of the security coverage for the site's installed minor version including final 8.x LTS releases (already committed on the 8.9.x and 9.0.x branches), so I hope this patch will be accepted. Given the limited lifetime of the 8.8.x branch, I do not think we need to back-port this patch, but it should also be applied to the 9.0.x branch. I just checked, and the patch applies cleanly to that branch.

dww’s picture

Thanks for the RTBC! And for updating the summary. ;)

Re: backporting, since the plan is for #2991207: Drupal core should inform the user of the security coverage for the site's installed minor version including final 8.x LTS releases to be backported, I think this should go with it. I originally hoped this would have happened in the parent issue as part of the "docs gate", etc. Ultimately, up to core maintainers. /shrug.

Cheers,
-Derek

dww’s picture

p.s. Opened #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class to officially allow @see static:myMethod(). Would love your support over there, too. ;)

Thanks!
-Derek

xjm’s picture

Status: Reviewed & tested by the community » Needs work
  1. Several docs lines in the patch are 81 characters long, and some are not indented correctly (e.g. the @todo at the top).

  2. +++ b/core/modules/update/src/ProjectSecurityData.php
    @@ -148,6 +148,10 @@ public function getCoverageInfo() {
    +   *    on a hard-coded constant (self::CORE_MINORS_WITH_SECURITY_COVERAGE).
    

    Our standard is to use static instead of self for reasons I don't remember.

  3. +++ b/core/modules/update/src/ProjectSecurityData.php
    @@ -165,7 +169,31 @@ private function getSecurityCoverageUntilVersion() {
    +   * The Drupal Security Team policy is currently to provide security coverage
    +   * for 2 minor release cycles. Some examples of how this function behaves:
    

    I don't think this documentation belongs here. If anything it belongs on the constant, but this is exactly the kind of thing that we'll miss updating if we change it. If anything, we should link the release cycle overview section on security coverage instead of writing this in the codebase.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new4.94 KB
new2.41 KB

@xjm re: #13:
1. Fixed. Also corrected the other @todo indentation that was added in the parent issue.

2. Changed. I don't believe we actually have a standard. ;) See #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class -- core uses both @see static::* and @see self::*, and @see self::* is more common. /shrug

3. The problem with not mentioning the policy is that all the examples (which at least @benjifisher and I believe are helpful) only make sense if you know the policy. I fear you're going to say "then take out all the examples, since we'd have to change those, too." This is why I wrote the patch originally as I did to say "The Drupal Security Team policy is currently..." with plenty of pointers to both where in the code this policy is currently expressed and the @todo where I/(we?) want to move this from a hard-coded constant to a value in the release history feeds. Not sure exactly what to do here to satisfy everyone. For now, it's this:

   * Some examples of how this function behaves:
   *
   * If the currently installed version of Drupal is 8.7.11, it should be
   * supported until the 8.9.0 release is published. If the latest official
   * ...

Thanks,
-Derek

benjifisher’s picture

Status: Needs review » Needs work
  1. I checked that the patch in #14 fixes the long lines and indentation.
  2. I reviewed the coding standards, and I could not find one that applies, either. We are not using @see here, but #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class does seem close enough to be relevant.
  3. Maybe we should consider rewriting this comment.

What do you think of moving the new @todo comment to the declaration of CORE_MINORS_WITH_SECURITY_COVERAGE? Then we would not need a reference.

I think that part of the difficulty is that getAdditionalSecurityCoveredMinors() does not really describe what the function does. Changing it is out of scope for this issue. Besides, additionalMinorReleasesDuringWhichThisOneReceivesSecurityUpdates() is ridiculous.

What do you think of something like this?

For the sake of example, assume that the currently installed version of Drupal is 8.7.11 and that static::CORE_MINORS_WITH_SECURITY_COVERAGE = 2.

When Drupal 8.9.0 is released, the supported minor versions will be 8.8 and 8.9. At that point, Drupal 8.7 will no longer have security coverage and this function will return 0.

After the release of Drupal 8.8.0 and before the release of 8.9.0, this function will return 1.

Before the release of Drupal 8.8.0, this function will return 2.

Note: callers should not test this function's return value with empty() since 0 is a valid return value that has different meaning than NULL.

Choosing 8.7.11 for an example is a little odd, since we know that this patch (and the parent issue) will not be back-ported to the 8.7.x branch. But it has the advantage that we know the policy in effect when 8.7.11 was released. I do not care strongly, but it might make more sense to use 9.0, 9.1, and 9.2 in the examples.

I would also be happy to move the examples to the doc block of getSecurityCoverageUntilVersion(). If we do that, then the comment might read

For the sake of example, assume that the currently installed version of Drupal is 8.7.11 and that static::CORE_MINORS_WITH_SECURITY_COVERAGE = 2. When Drupal 8.9.0 is released, the supported minor versions will be 8.8 and 8.9. At that point, Drupal 8.7 will no longer have security coverage. Therefore this function returns "8.9.0".

benjifisher’s picture

Issue summary: View changes
dww’s picture

Status: Needs work » Needs review
StatusFileSize
new5.37 KB
new3.02 KB

@benjifisher: Thanks for the reviews / updates!

What do you think of moving the new @todo comment to the declaration of CORE_MINORS_WITH_SECURITY_COVERAGE? Then we would not need a reference.

Love it. Done.

Besides, additionalMinorReleasesDuringWhichThisOneReceivesSecurityUpdates() is ridiculous.

Hah! :) 👍

What do you think of something like this?

Mostly seems great. However, I inverted the order of the examples so they read chronologically, which seems to make more sense than the order you had. Did a few other minor updates / additions / merges with the previous example text from #14. Also, I left the 9.*.* example as a simplified paragraph after all the 8.7.* examples.

I would also be happy to move the examples to the doc block of getSecurityCoverageUntilVersion().

I think the examples explaining return values of 0 vs. 1 vs. 2 are really helpful for getAdditionalSecurityCoveredMinors(). However, I think your comment text also helps clarify getSecurityCoverageUntilVersion(), which seems totally in scope for this issue. So I added that, too. ;)

Thanks,
-Derek

benjifisher’s picture

Status: Needs review » Needs work

Thanks, I think the version in #17 is an improvement. The only thing I do not like is repeating the text

... the supported minor versions will be 8.8 and 8.9. At that point, Drupal 8.7 will no longer have security coverage ...

I am willing to go along if you think it really helps, but my suggestion is to remove it from the second doc block.

By the way, one of the comments that is tweaked in this issue now reads

        // The releases are ordered with the most recent releases first.
        // Therefore, if we have found a published, official release with the
        // same major version as $security_covered_version, then this release
        // can be used to determine the latest minor.

I looked at the docs for the Update status XML feed, and it says nothing about "most recent releases first". Since we are relying on that, I could just edit that page and hope that it is considered a requirement, but maybe I will post something to the #drupalorg Slack channel instead.

dww’s picture

StatusFileSize
new5.35 KB
new1.05 KB

Was hoping to chat in Slack about this before uploading another patch, since I hate having the test bot run ~30K tests on a doc-only patch. ;)

But I think this addresses the concerns in #18 about the duplicate text (in different doc blocks, so I'm not sure it really matters).

Re: "most recent releases first"... update.module has always depended on that. I see the Slack thread about it, and @drumm updated the release history feed API docs to mention this. But yeah, that's nothing new, and nothing to worry about.

Thanks for all the thorough reviews!

RTBC?

dww’s picture

Status: Needs work » Needs review
dww’s picture

Title: Improve code documentation for ProjectSecurityData::getAdditionalSecurityCoveredMinors() » Improve code documentation for \Drupal\update\ProjectSecurityData
Issue summary: View changes

Since this is improving more than just getAdditionalSecurityCoveredMinors(), widening the scope of the title and summary.

Also updating remaining tasks. We're back to "needs review". ;)

Thanks,
-Derek

dww’s picture

StatusFileSize
new5.35 KB
new706 bytes

Whoops. s/would would/would return/

benjifisher’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Thanks for the requested changes in #19 and #22. As far as I am concerned, this patch is good to go!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: 3111463-22.patch, failed testing. View results

dww’s picture

Status: Needs work » Reviewed & tested by the community

Random fail:
1) Drupal\Tests\media_library\FunctionalJavascript\WidgetUploadTest::testWidgetUploadAdvancedUi
"image-1.png" not found
Failed asserting that a boolean is not empty.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: 3111463-22.patch, failed testing. View results

dww’s picture

Status: Needs work » Reviewed & tested by the community

More random fails.

dww’s picture

StatusFileSize
new5.1 KB
new940 bytes

Re-roll. Still RTBC.

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.

  • xjm committed 68c5399 on 9.1.x
    Issue #3111463 by dww, benjifisher, xjm: Improve code documentation for...

  • xjm committed 319856e on 9.0.x
    Issue #3111463 by dww, benjifisher, xjm: Improve code documentation for...

  • xjm committed 2cfa952 on 8.9.x
    Issue #3111463 by dww, benjifisher, xjm: Improve code documentation for...

  • xjm committed f1a56af on 8.8.x
    Issue #3111463 by dww, benjifisher, xjm: Improve code documentation for...
xjm’s picture

Version: 9.1.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Fixed
+++ b/core/modules/update/src/ProjectSecurityData.php
@@ -144,6 +150,12 @@ public function getCoverageInfo() {
+   * coverage. Therefore this function would return "8.9.0"

Ubernit: Missing comma after "therefore" and missing final period.

That's trivial enough that I'll fix it on commit:

diff --git a/core/modules/update/src/ProjectSecurityData.php b/core/modules/update/src/ProjectSecurityData.php
index 59b36e1cee..45068978fa 100644
--- a/core/modules/update/src/ProjectSecurityData.php
+++ b/core/modules/update/src/ProjectSecurityData.php
@@ -154,7 +154,7 @@ public function getCoverageInfo() {
    * Drupal is 8.7.11 and that static::CORE_MINORS_WITH_SECURITY_COVERAGE is 2.
    * When Drupal 8.9.0 is released, the supported minor versions will be 8.8
    * and 8.9. At that point, Drupal 8.7 will no longer have security
-   * coverage. Therefore this function would return "8.9.0"
+   * coverage. Therefore, this function would return "8.9.0".
    *
    * @todo In https://www.drupal.org/node/2998285 determine how we will know
    *    what the final minor release of a particular major version will be. This

Committed to 9.1.x, 9.0.x, 8.9.x, and 8.8.x as a documentation improvement. Thanks!

dww’s picture

Status: Fixed » Needs review
StatusFileSize
new974 bytes

Thanks!

+++ b/core/modules/update/src/ProjectSecurityData.php
@@ -144,6 +150,12 @@ public function getCoverageInfo() {
+   * and 8.9. At that point, Drupal 8.7 will no longer have security
+   * coverage. Therefore, this function would return "8.9.0".

While we're ubernitting, 'coverage.' fits on the previous line. Whoops.

Can we just fix that here, or do we need a whole new issue for this?

dww’s picture

Status: Needs review » Reviewed & tested by the community

Bot's happy. This is so trivial, I'm gonna self-RTBC. Hope we can just fix this here instead of jumping through hoops for a new issue.🤞

  • xjm committed e59eed9 on 9.1.x
    Issue #3111463 followup by dww: Fix line wrapping
    

  • xjm committed 9636e01 on 9.0.x
    Issue #3111463 followup by dww: Fix line wrapping
    
    (cherry picked from...

  • xjm committed 10755cf on 8.9.x
    Issue #3111463 followup by dww: Fix line wrapping
    
    (cherry picked from...

  • xjm committed f912145 on 8.8.x
    Issue #3111463 followup by dww: Fix line wrapping
    
    (cherry picked from...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

OK, sure. Thanks!

dww’s picture

Thank you! :)

Cheers,
-Derek

Status: Fixed » Closed (fixed)

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