Problem/Motivation

There is a single call to ModuleHandler::loadAllIncludes() in core and never should have been using that in the first place. Searching in contrib, there are a few module handler subclasses and decorators and maybe 2-3 somewhat valid calls for loading all install files, one is schema module.

There is one in xmlsitemap, which calls its own requirements hooks.

Steps to reproduce

Proposed resolution

Deprecate for D13, remove call in search module.

Remaining tasks

User interface changes

Introduced terminology

API changes

ModuleHandler::loadAllIncludes() is now deprecated.

Data model changes

Release notes snippet

Issue fork drupal-3536431

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

berdir created an issue. See original summary.

berdir’s picture

Status: Active » Needs review
nicxvan’s picture

This is on my list to fully review.
First pass this looks great.

One thing though:

which are already deprecated too.

that is not quite right, hook_requirements isn't deprecated yet.

oily’s picture

RE: #4 @nicxvan I cannot see where that text appears? Has it been corrected now?

nicxvan’s picture

It's in the issue summary.

oily’s picture

Made the CR a bit clearer, though now Im not sure if @berdir means '... loadAllInclude() can be used in a loop for modules'? maybe 'used in a loop for includes'?

oily’s picture

Issue summary: View changes
oily’s picture

RE: #6 updated IS.

nicxvan’s picture

Issue summary: View changes

I don't follow your changes to the issue summary.

What do you mean by

all these are already deprecated.

nothing there is deprecated.

And again

There is one in xmlsitemap, which calls its own requirements hooks. However it is not yet deprecated.

My point was that hook_requirements is not deprecated, there is no need at all to mention deprecation regarding it.

I've updated the IS to remove references to deprecation.

@berdir the one thing I'm struggling with is if removing $this->moduleHandler->loadAllIncludes('admin.inc'); works, why don't we just do that in the other issue.

What is the purpose of deprecating this here and now? Is it to just move down the road of discouraging .inc files?

Or is it more that this is so rarely used and fairly easy to replicate that we might just want to deprecate to slim down ModuleHandler a bit?

We might want to update the CR in that case to mention that deprecating include files is more future, the CR kind of implies they are deprecated with this change.

nicxvan’s picture

All that said I reviewed the MR, all deprecations are correct, tests are updated. This is the way to do it if we move forward here.

I'm not going to go as far as tagging this needs framework manager review, but it might need confirmation of the direction we're going.
This just feels different than the magic loading we were doing with hook_info. This is more of a utility method.

Again, not opposed to this, just looking for a bit more on it.

berdir’s picture

@berdir the one thing I'm struggling with is if removing $this->moduleHandler->loadAllIncludes('admin.inc'); works, why don't we just do that in the other issue.

What is the purpose of deprecating this here and now? Is it to just move down the road of discouraging .inc files?

Yes, it's one small step toward removing cruft from ModuleHandler.

But also, by leaving deprecated .inc files in core, we soft-deprecate this already. Once the system issue is in, you couldn't call it with 'admin.inc' without triggering a deprecation. And once for example the views issue is in, you couldn't call it with 'theme.inc'.

And last, removing that call in the system.module issue is IMHO out of scope, so I'd want to do a separate issue anyway.

There is one in xmlsitemap, which calls its own requirements hooks. However it is not yet deprecated.

It's relevant because I reviewed usages for this method in contrib. There are exactly 3 calls, all of them use it to load all .install files. One of those to call requirements hooks.

hook_requirements() isn't officially deprecated, but it's kind of a formality at this point. We have all replacements in place, core is fully converted except one test hook (no alter hook test though, that was converted too). We discussed that in the requirements deprecation issue, IMHO the current state is a problem because it's unclear how modules are supposed to convert while remaining compatible with older versions, which I think is important. I'll try to make a proposal on that issue, but yes, all is unrelated to this issue.

The only bit that's related is that we do want to and will deprecate that, so that code will need to move way from loadAllIncludes() anyway.

oily’s picture

RE: #10 I also edited the CR.

xjm’s picture

Title: Deprecate ModuleHandler::loadAllIncludes » Deprecate ModuleHandler::loadAllIncludes()
oily’s picture

RE:10 The source of my confusion was the idea of 'Include files'. If it had said '.inc' files that makes immediate sense to me. On the other hand the function allows the file extension to be specified so not only '.inc' extension. This seems to be why hooks are mentioned in the IS..

But then looking in core, the one instance of loadAllIncludes() is

loadAllIncludes(type: 'admin.inc')

but the 'type' parameter is supposed to be the file extension, not the whole filename. To load all files named 'admin.inc' the function would need to be

loadAllIncludes(type: 'inc', name: 'admin')

So it seems this one instance of the function in core does nothing at all, not even throw an exception.

nicxvan’s picture

.admin.inc is the file extension.

I made an attempt to clarify the CR that could use another review.

Once that is done I think the code side of this is ready.

oily’s picture

Status: Needs review » Reviewed & tested by the community
oily’s picture

The new CR draft is good. RTBTC.

nicxvan’s picture

Issue summary: View changes
berdir’s picture

The arguments to the load include functions are super confusing, IIRC you'd only use the name argument if it wouldn't start with the module name.

  • catch committed 1d1c8783 on 11.x
    Issue #3536431 by berdir, oily, nicxvan: Deprecate ModuleHandler::...

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks! Published the CR.

Status: Fixed » Closed (fixed)

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