Problem/Motivation

We have made several class final and internal lately for the Update module.

  • \Drupal\update\ProjectSecurityData
  • \Drupal\update\ProjectSecurityRequirement
  • \Drupal\update\ModuleVersion

These methods have to do with internal logic and should not be called directly and should not be extended

We should also do this with \Drupal\update\ProjectCoreCompatibility. This class has not be backported to 8.8.x so I think if we do it now it should be fine.

Nobody should extend this or call it directly.
If some wants the compatiblity message they can call update_calculate_project_data() making this class final has no effect on this. Because update_calculate_project_data() is existing global function we can't do anything to prevent from being an API.

I don't think we should consider our core compatibility messages an API but If a site wants a different message they can implement hook_update_status_alter() and unset core's message and make their own. Again because update_calculate_project_data() is existing global function we can't really prevent that. Our message should not be extendable besides translation. So there is no need for this class to be called directly or extended.

Proposed resolution

Make it final and internal

Remaining tasks

User interface changes

None

API changes

The class will be final and internal

Data model changes

none

Release notes snippet

none, it wasn't in 8.8.x

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tedbow created an issue. See original summary.

tedbow’s picture

patch

tedbow’s picture

Status: Active » Needs review
tedbow’s picture

dww’s picture

Status: Needs review » Reviewed & tested by the community

I guess I'm +1 to this change. However, this bit from the summary seems a little unfortunate:

If some needs the compatiblity message they should call update_calculate_project_data().
If they want a different message they can implement hook_update_status_alter() and unset core's message and make their own. Our message should not be extendable besides translation.

I thought we hated the procedural "API" (such as it is) for Update module. Seems like a wonky thing to recommend people do if they need this info. I know that's a whole bigger / different problem.

Certainly #3113992: The 'Update' page has no idea that some updates are incompatible can do what it needs without touching this class. So that's a good argument that this class really doesn't need to be called directly by anyone outside of update_calculate_project_data().

So, okay, I guess I convinced myself. Let's do this.

dww’s picture

Title: Make ProjectCoreCompatibility class final and internal » [PP-1] Make ProjectCoreCompatibility class final and internal
Status: Reviewed & tested by the community » Postponed

Upon closer review:

  1. +++ b/core/modules/update/src/ProjectCoreCompatibility.php
    @@ -8,8 +8,12 @@
      * Utility class to set core compatibility messages for module updates.
    

    This line of context is changing upstream, so this patch probably won't apply cleanly after #3102724: Improve usability of core compatibility ranges on available updates report lands. Not much we can do about it now, but I'd be in favor of postponing this on making sure that lands first so we don't derail anything...

  2. +++ b/core/modules/update/src/ProjectCoreCompatibility.php
    @@ -8,8 +8,12 @@
    + * @internal
    + *   This class implements internal logic for the Update module. It should not
    + *   be called directly.
    

    This comment doesn't add anything beyond what @internal already says. I'm not sure what to do about that. I believe our standards (not sure they're documented) are to have a comment with @internal declarations. But saying, in effect: "this is internal and is internal and should not be called externally" seems pointless.

How about something like this for the comment:

 * @internal
 *   This class implements logic used by update_calculate_project_status().
 *   It should not be called directly.
 *
 * @see update_calculate_project_status()

(approx).

Thanks,
-Derek

tedbow’s picture

Version: 8.9.x-dev » 8.8.x-dev
Issue summary: View changes
Status: Postponed » Needs review
FileSize
622 bytes

@dww thanks for the feedback and suggestions.
re #5 I updated the summary. I just meant to say there ways to change and retrieve the message that we can't really prevent given how things work now. No need to make yet another API point

re #6

  1. For 8.9.x that is true but since your comment this class has been added to 8.8.x since #3096078: Display core compatibility ranges for available module updates was backported. Since we are closer to having a 8.8.x release than 8.9..x this is more important to get into 8.8.x so it is never in a full release with being final and internal.
  2. Updating to your suggestion.
tedbow’s picture

Issue summary: View changes
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Looks great

tedbow’s picture

Title: [PP-1] Make ProjectCoreCompatibility class final and internal » Make ProjectCoreCompatibility class final and internal
FileSize
624 bytes

Here is patch for 8.9.x.

They are different because #3102724: Improve usability of core compatibility ranges on available updates report hasn't been committed yet to 8.8.x because it needs #3074993: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates

#3102724 changed the class comment so it makes the diff different(I gotta remember fight harder to keep scope small 😜)

dww’s picture

Status: Reviewed & tested by the community » Needs work

Hate to do this for ridiculous nits, but I suspect the core committers will notice, so we might as well fix it, first:

+++ b/core/modules/update/src/ProjectCoreCompatibility.php
@@ -8,8 +8,12 @@
+ * @internal
+ *   This class implements logic used by update_calculate_project_status(). It
+ *    should not be called directly.

Improper indenting (extra space) on the 2nd line of the comment.

Otherwise, all +1 here.

Thanks!
-Derek

dww’s picture

Version: 8.8.x-dev » 8.9.x-dev
Status: Needs work » Needs review
FileSize
617 bytes
615 bytes
474 bytes

Fixed #11.
My preference would be for #3102724: Improve usability of core compatibility ranges on available updates report to land in 8.8.x first, then the 8.9.x patch here should cleanly apply.
Otherwise, here's an 8.8.x-specific patch if needed.

tedbow’s picture

Status: Needs review » Reviewed & tested by the community

@dww thanks for catching that

Gábor Hojtsy’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Fixed

I agree it makes sense to be more limited in terms of our API surface with stuff we do not intend people to use. Good call.

Status: Fixed » Closed (fixed)

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