Problem/Motivation
Hook requirements uses phase right now to manage whether it is runtime, install, or update.
This leads to significant complexity. As it stands hook_runtime can easily be an OOP hook.
Let's create a new hook_runtime_requirements() so we can start moving those.
Steps to reproduce
N/A
Proposed resolution
Create hook_runtime_requirements()
Create hook_runtime_requirements_alter()
Invoke hook_runtime_requirements() after hook_requirements()
Merge results
Run hook_requirements_alter()
Run hook_runtime_requirements_alter()
Remaining tasks
None
User interface changes
N/A
Introduced terminology
API changes
hook_runtime_requirements()
hook_runtime_requirements_alter()
Can be implemented to provide our alter requirements on status report.
Data model changes
Release notes snippet
Issue fork drupal-3490841
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:
- 3490841-create-hookruntimerequirements
changes, plain diff MR !10410
Comments
Comment #2
nicxvan commentedComment #4
nicxvan commentedComment #5
nicxvan commentedComment #6
nicxvan commentedComment #7
nicxvan commentedComment #8
nicxvan commentedComment #9
smustgrave commentedThink the CR should be updated with some code examples
Also some test coverage for the hooks to show they work.
Comment #10
nicxvan commentedUpdated both.
Comment #11
nicxvan commentedDidn't push up the alter test.
Comment #12
nicxvan commentedComment #13
nicxvan commentedComment #14
smustgrave commentedI don't think we need to convert all here but could we convert least 1-2 instances to use this new hook. With the test coverage I do believe it's working but it being used live would be great.
Comment #15
nicxvan commentedComment #16
smustgrave commentedAppears to have a pipeline issue. But keeping an eye out for this one.
Comment #17
smustgrave commentedThanks for adding that example!
Rest looks good to me
Comment #18
dwwThanks for this! Exciting.
I’m only looking at the MR on my phone. I have some concerns. I’ll post a thorough review later when I’m not thumb-typing.😅 But I don’t believe this is totally ready in its current state. No rush, since this isn’t happening for 11.1.x. But getting out of the RTBC queue for now so committers don’t waste time on it.
Comment #19
dwwOr I guess to make @smustgrave happy, NW is better. 😂 Sorry to change the status to that without explanation, but I’ll open MR threads later with details.
Comment #20
alexpottI'm not sure about the decisions that are creating this API. It feels like the question is how can we make this an OOP hook - and not what is the correct API for gathering requirements during install, update and runtime. The solution being advocated for in this and the other issues feels just asking ourselves what is possible with OOP hooks - and not what it is the correct API for gathering requirements from modules.
Comment #21
nicxvan commentedI'll reply on the meta.
Comment #22
nicxvan commentedMarking this postponed since an alternate approach was suggested in the Meta
Comment #23
nicxvan commentedComment #24
dwwThe MR thinks the merge is blocked due to conflicts. Would you be willing to rebase? I just did a thorough review on the sister issue. Probably many of those nits would apply here, too. ;) I'm sadly out of contrib time for today, so I'll have to come back to this later for a more thorough review of the details here.
Comment #25
nicxvan commentedThanks! I can rebase and transfer the feedback here too tomorrow.
Comment #26
nicxvan commentedI applied all feedback from #3490842: Create hook_update_requirements() and hook_update_requirements_alter()
Comment #27
nicxvan commentedComment #28
nicxvan commentedComment #29
smustgrave commentedBelieve after this rebase this one is good to go.
Re-ran the pipeline and all failures were random.
CR reads well with the examples and conversion in the file module believe shows it works in real time.
Comment #30
dwwNeeds rebase after #3498059: Add array return to all hook_requirements implementations landed. Also, added a bunch of suggestions to cleanup the API docs.
Initial pass at saving credit: @nicxvan for all the work, and @smustgrave and myself for reviews.
Comment #31
nicxvan commentedI think the failure is from upstream, nothing here would make the navigation stylesheet larger.
I think it may be here #3425081: Integrate Navigation with Workspaces
I pushed up another change to a comment and the same job is failing.
It's possible I made a mistake rebasing, but the changes look right and the performance test assertion matches HEAD.
I bumped the value here so it passes, but also created #3500293: Add headroom to the navigation performance test
Comment #32
nicxvan commentedComment #33
dwwEdit: whoops, wrong issue.
Comment #34
dwwThis, too, might be RTBC, but lemme do it right if true.
Comment #35
dwwYeah, I don’t know if the quick-fix here in an unrelated test is the right approach. I believe we should postpone this on resolving #3500293: Add headroom to the navigation performance test
Comment #36
dwwBlocker is in. This needs a rebase and to revert the last commit.
Comment #37
nicxvan commentedYep I'll take care of it
Comment #38
dwwPhew! Thanks for sticking with this through all the rounds of reviews. Apologies I didn't spot everything all at once.
Everything is ready here now. Pipeline is green. Code and docs have been polished so much they shine. 😂 No other improvements I can spot. Per the meta, these separate hooks really are the right approach for splitting up the beast of
hook_requirements().Ready To Be Committed. 😉
Comment #39
dwwp.s. Did a light edit on the CR for formatting and pedantic nits. 😂 https://www.drupal.org/node/3490851/revisions/view/13843726/13854897
Comment #40
alexpottCommitted 5e0a4ce and pushed to 11.x. Thanks!
Comment #41
alexpott