Problem/Motivation

When trying to post a new topic as a non-admin user, the website throws an error:
Error: Call to undefined function forum_access_get_settings_by_user() in forum_access_form_node_form_get_available_tids() (line 798 of modules/contrib/forum_access/forum_access.module).

Proposed resolution

The module includes/forum_access.acl which contains the function forum_access_get_settings_by_user() seems not to be loaded. Add this line above line 798:

module_load_include('inc', 'forum_access', 'includes/forum_access.acl');
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

Tramb created an issue. See original summary.

Tramb’s picture

Hi,
Here the patch to fit with my proposed resolution.

salvis’s picture

Version: 8.x-1.0-alpha3 » 8.x-1.x-dev
Status: Active » Needs review

I wonder why no one else seems to have this problem...

salvis’s picture

Status: Needs review » Closed (cannot reproduce)
aimai’s picture

Status: Closed (cannot reproduce) » Active

Re-opening the issue as we've run into it recently as well.

It seems like in some cases forum_access_form_node_form_get_available_tids is called before the forum_access.acl file is included, resulting in the above error.

aimai’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

nico.b’s picture

Status: Active » Reviewed & tested by the community

I can confirm that this issue exists, and that the provided MR fixes the issue.

I think the reason why not many people experience this issue is that - as far as I could tell - it only appears if forum_access_form_node_form_get_available_tids is called "outside" of the "normal" flow of the module (e.g. by a custom module). Imho, it's still a flaw in the implementation of `forum_access_form_node_form_get_available_tids` though since a caller shouldn't be responsible to load any dependencies of the called method (since the caller can't know what needs to be loaded). Therefore, the fix makes sense in my opinion.

nevergone’s picture

I tested it and this error does occur when calling the forum_access_form_node_form_get_available_tids() function from outside. The attached patches fix the error.

  • nevergone committed 04fbb8f0 on 2.0.x authored by aimai
    [#3302353] fix: Module ACL access not loaded when checking forum access...
nevergone’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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