Problem/Motivation

We need to add stubs for the order parameter and objects for: #3485896: Hook ordering across OOP, procedural and with extra types i.e replace hook_module_implements_alter
Long discussion in slack: https://drupal.slack.com/archives/C079NQPQUEN/p1741870906383859

Basically since the order parameter and associated objects will not exist and will create a fatal error. We can add the order parameter earlier and stubs for the objects. This will prevent fatal errors.

Steps to reproduce

N/A

Proposed resolution

Add new Hook signature
Add Attributes and Order objects
Update docs to mention 11.2 +

Remaining tasks

N/A

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#11 3512835-nr-bot.txt91 bytesneeds-review-queue-bot

Issue fork drupal-3512835

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

nicxvan created an issue. See original summary.

nicxvan’s picture

Issue summary: View changes
catch’s picture

Priority: Normal » Critical

This seems critical for 11.1.x and very nice to have for 11.0.x and lower.

nicxvan’s picture

Title: Add BC stubs for Hook ordering. » [11.1.x] Add BC stubs for Hook ordering.
Version: 11.x-dev » 11.1.x-dev

nicxvan changed the visibility of the branch 3512835-add-bc-stubs to hidden.

nicxvan changed the visibility of the branch 11.x to hidden.

nicxvan changed the visibility of the branch 3512835-bc-stubs to hidden.

nicxvan’s picture

Issue summary: View changes
Status: Active » Needs review
needs-review-queue-bot’s picture

Status: Needs review » 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.

nicxvan’s picture

Status: Needs work » Needs review
Issue tags: +no-needs-review-bot

I think the bot is trying to merge with HEAD

smustgrave’s picture

Appears to have pipeline issues

nicxvan’s picture

Gitlab is not picking up my change, I fixed this 5 hours ago, and now I cannot apply a suggestion to it.

smustgrave’s picture

I tried too and got a “file has been changed”

Wonder if 11.1x branch permission?

nicxvan’s picture

New commit worked.

smustgrave’s picture

Status: Needs review » Needs work

Moving to NW because all the tests appear to be failing

dww’s picture

PHP Fatal error: Uncaught Error: Call to undefined method Drupal\Core\Hook\Attribute\Hook::setMethod() in /builds/issue/drupal-3512835/core/lib/Drupal/Core/Hook/HookCollectorPass.php:289

nicxvan’s picture

Yeah I forgot a method, I'll move it in later tonight.

nicxvan’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

All seems good now.

  • larowlan committed 81f5ac29 on 10.5.x
    Issue #3512835 by nicxvan: [11.1.x] Add BC stubs for Hook ordering
    
    (...

  • larowlan committed 55dfb3cd on 11.0.x
    Issue #3512835 by nicxvan: [11.1.x] Add BC stubs for Hook ordering
    
    (...

  • larowlan committed 64bfef04 on 11.1.x
    Issue #3512835 by nicxvan: [11.1.x] Add BC stubs for Hook ordering
    
larowlan’s picture

Version: 11.1.x-dev » 10.5.x-dev

Committed to 11.1.x and backported to 10.5.x and 11.0.x

larowlan’s picture

Status: Reviewed & tested by the community » Fixed
donquixote’s picture

Did the PREFIX and SUFFIX need backporting?

  • larowlan committed 7800942b on 10.5.x
    Revert "Issue #3512835 by nicxvan: [11.1.x] Add BC stubs for Hook...
larowlan’s picture

Status: Fixed » Needs work

The 10.5.x backport failed - we're using readonly properties here which aren't allowed on the versions of PHP 10.x supports

nicxvan’s picture

I can roll a 10.5 specific if someone doesn't before me.

nicxvan’s picture

Title: [11.1.x] Add BC stubs for Hook ordering. » [10.5.x] Add BC stubs for Hook ordering.
nicxvan’s picture

Status: Needs work » Fixed

Created #3523163: [10.5.x] Add BC stubs for Hook ordering. because creating 10.5 from here was too out of date.

nicxvan’s picture

Title: [10.5.x] Add BC stubs for Hook ordering. » [11.1.x] Add BC stubs for Hook ordering.
donquixote’s picture

This MR did a lot more than what we need to for the BC support.
We absolutely don't need all these new attributes.
We only need to make the existing attributes compatible with new modules.
We did have a very clear plan for this, which we somehow forgot.

Missing attributes are ok, because we call ->getAttributes() with a type parameter. Only attributes classes with incompatible constructor signature are a problem.

We should either revert this and do again, or remove all the changes we don't need.
And before the next release for 11.1.x or 11.0.x. (if that has not already happened, I am not following).

nicxvan’s picture

We did have a very clear plan for this, which we somehow forgot.

I'm not sure what plan you are referring to, we backported Hook and LegacyHook to 10.4 as part of the original OOP hook initiative so we followed the same here.

In this case the Order classes are required otherwise there would be a fatal, and since we backported Hook already we need to backport those as well to all branches.

None of the plumbing for collection or ordering was backported, why are you concerned about backporting these classes, what could it possibly affect, they are not used.

donquixote’s picture

(recap of what I said in slack)

My concern is this:

We have a grace period before 11.2.0 to tweak api details of the new attributes and API features we are adding.
But whatever we put into older versions of Drupal may get released before 11.2.0, as part of a minor release. At that point we can no longer change these, so we are cutting that grace period short.

Also for disruptive future changes to the new attributes, we now will need to cater to the 10.5.x, 11.0.x and 11.1.x as well.
Worse, we could have contrib modules written for 11.2.x that are compatible with 10.5.x but not with 10.6.x, or vice versa, because we just backported another change.

You are correct about order classes though, we do need these in any branch that collects hook attributes.
(more below)

I'm not sure what plan you are referring to

I remember a discussion where we determined that missing attributes are not a problem, only incompatible constructors.
The conclusion was that we update existing attributes in older versions where they exist, to allow alternative parameters, but that we don't backport all new attribute classes.

For concerns with phpstan, I am sure this can be handled in some way.

we backported Hook and LegacyHook to 10.4 as part of the original OOP hook initiative

I would have complained about backporting hook attribute to 10.x, but I probably did not pay attention at the time.

In this case the Order classes are required otherwise there would be a fatal, and since we backported Hook already we need to backport those as well to all branches.

This is correct, we do have to backport the order classes to any branch which has the Hook attribute class, OR any branch where we actually collect hook attributes.
But this also means: If we had not backported the Hook class to 10.x, we now would not have to create BC stubs for 10.x.

None of the plumbing for collection or ordering was backported, why are you concerned about backporting these classes, what could it possibly affect, they are not used.

The attribute classes are part of public API, the plumbing is not.
In general, releasing public API features is easy, the problem is that we cannot easily remove or change them later.

donquixote’s picture

Status: Fixed » Closed (fixed)

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