http://api.drupal.org/api/function/module_load_include/6

Currently:

$name Optionally, specify the file name.  If not set, the module's name is used.

What is meant is specify the file name without extension. However, the term "file name" includes the file extension: http://wikipedia.org/wiki/Filename. Therefore, the text should be corrected to

$name Optionally, specify the file name without extension.  If not set, the module's name is used.

From looking at the parameters you might guess that the file name should be specified without an extension, but the parameter description should be explicit and precise so no guessing is needed.

Comments

threexk’s picture

Title: module_load_include $name parameter needs clarification » module_load_include() $name parameter needs clarification
jhodgdon’s picture

Version: 6.x-dev » 7.x-dev
Status: Active » Needs review
StatusFileSize
new697 bytes

Should be patched in D7 and then ported back to D6.

Here's a patch.

Status: Needs review » Needs work

The last submitted patch failed testing.

jhodgdon’s picture

Status: Needs work » Needs review

Setting back to Needs Review in hopes that the patch will get retested. The test bot was apparently malfunctioning (I had about 7 patches fail in that time period, all were doc, none broke the HEAD install I am pretty sure).

Status: Needs review » Needs work

The last submitted patch failed testing.

jhodgdon’s picture

Status: Needs work » Needs review

Test bot still not working?

threexk’s picture

Thanks for making a patch. It applied fine for me. My Drupal HEAD broke when I updated it from CVS and I had to drop the database and reinstall to get things working. Maybe the test bot has the same problem? (Or maybe I'm just updating from CVS incorrectly -- cvs update -PCdR)

moshe weitzman’s picture

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

Status: Reviewed & tested by the community » Needs work

You know, in reading this, it's sufficiently confusing that we could really do with a @code example to make it more clear.

jhodgdon’s picture

That's a thought... although if you are on api.drupal.org, you can of course click on one of the 17 functions that call this function to get an example... I'll see about adding an example though.

jhodgdon’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

How about this patch: same text, addition of two examples?

threexk’s picture

Might it be better if the syntax of the function was changed to:
module_load_include($module, $filename)
So for example:
module_load_include('node', 'node_admin.inc');
This would cause some redundancy in the parameters like:
module_load_include('node', 'node.install');
But is it really that bad? This form of the function seems a whole lot clearer to me and would be easier to document. It also seems like the third parameter to the current function gets used a lot.

threexk’s picture

I grepped one of my 6.x sites. There are 82 calls to module_load_include(). Of those, 68 use the third parameter to module_load_include(). That's 83%.

So most of the time the current form of module_load_include isn't useful. I think the two-parameter form I suggested would be better because it's simpler and it's briefer for the common case.

jhodgdon’s picture

+1 on this idea. However, I think it should be filed as a separate issue against the core of Drupal 7 (there is zero chance it would be changed in Drupal 6, due to the way it would break a ton of contrib modules). The present issue is a doc issue that affects D6 and D7 (in its current state).

webchick’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs review » Reviewed & tested by the community

I agree with both. The function signature makes absolutely no sense and should be changed in 7.x, and the documentation that's currently there for the function is confusing. So let's keep this issue to just the docs stuff, and start a separate issue for "Make module_load_include() actually make sense" :) Please reference threexk's findings, as that's a very compelling case for changing the function signature.

Committed to HEAD. Still applies to 6.x with offset, so marking RTBC there.

threexk’s picture

Added http://drupal.org/node/507396 for the module_load_include() change proposal.

dave reid’s picture

Version: 6.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Needs work

BTW, the example to load an install file should not be using module_load_include(). It should be module_load_install() since that also loads install.inc. A better example would be module_load_include('inc', 'node').

threexk’s picture

Dave Reid: You're right, but there's no node.inc ...

Regarding the second example, couldn't you do
module_load_include('admin.inc', 'node');
instead of
module_load_include('inc', 'node', 'node.admin');

I should try it, but if it works I'm not sure the current example demonstrates the necessity of the third parameter. What about:
module_load_include('inc', 'node', 'content_types');

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new963 bytes

Followup HEAD patch for review.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Ha! I took that .install example from module_load_install(). :) Your patch of my patch looks good.

Then we should make a new one for D6.

webchick’s picture

Version: 7.x-dev » 6.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks, committed this to HEAD.

Marking down for 6.x.

jhodgdon’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.15 KB

Here's a patch for D6, incorporating the patches in #11 and #19 above.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

This patch was approved for D7, so updating status.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed to Drupal 6 too.

Status: Fixed » Closed (fixed)

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